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
36
37
38
39
class User
  :has_many :domains, :through => :domain_coordinators
  :has_many :regions, :through => :regional_coordinators
  def domains_responsible_for
    self.domains
  end
  
  def regions_responsible_for
    self.regions # Not very fast code... but will work
  end
  
end

class DomainCoordinator
  :belongs_to :user
  :belongs_to :domain
end

class RegionalCoordinator
  :belongs_to :user
  :belongs_to :region
end


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

class Region
  :has_many :domains
  :has_many :users, :through => :regional_coordinators
  def coordinators
    self.users
  end
end