Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class User
  :has_many :domains, :through => :coordinators
  def domains_responsible_for
    self.domains
  end
  
  def regions_responsible_for
    self.domains.regions # Not very fast code... but will work
  end
  
end


class Coordinators
  :belongs_to :user
  :belongs_to :domain
end


class Domain
  :has_many :users, :through => :coordinators
  :belongs_to :region
  def coordinators
    self.coordinators
  end
end

def Region
  :has_many :domains
  
  def coordinators
    self.domain.users
  end

end