Commit d47334895b19a95aac72c8dddf70640beb8f4720

Authored by Braulio Bhavamitra
1 parent c9c81cfa

Add memberships association for eager loading

Showing 1 changed file with 3 additions and 0 deletions   Show diff stats
app/models/person.rb
@@ -67,6 +67,9 @@ class Person < Profile @@ -67,6 +67,9 @@ class Person < Profile
67 end 67 end
68 alias_method_chain :has_permission?, :plugins 68 alias_method_chain :has_permission?, :plugins
69 69
  70 + # for eager loading
  71 + has_many :memberships, through: :role_assignments, source: :resource, source_type: 'Profile'
  72 +
70 def memberships 73 def memberships
71 scopes = [] 74 scopes = []
72 plugins_scopes = plugins.dispatch_scopes(:person_memberships, self) 75 plugins_scopes = plugins.dispatch_scopes(:person_memberships, self)