Commit 790373996df1772d432f255c80cc456d9bbf5047

Authored by Antonio Terceiro
1 parent 37e4ba3e

Using proper ActiveRecord relationships

All related tests still pass.

(ActionItem1659)
app/models/environment_mailing.rb
1 1 class EnvironmentMailing < Mailing
2 2  
3 3 def recipient(offset=0)
4   - Person.find(:first, :conditions => [ "environment_id = ?", source_id], :order => :id, :offset => offset)
  4 + source.people.first(:order => :id, :offset => offset)
5 5 end
6 6  
7 7 def each_recipient
... ...
app/models/organization_mailing.rb
... ... @@ -5,8 +5,7 @@ class OrganizationMailing &lt; Mailing
5 5 end
6 6  
7 7 def recipient(offset=0)
8   - environment_id = source.environment_id
9   - Person.find(:first, :conditions => ['environment_id = ? and role_assignments.resource_type = ? and role_assignments.resource_id = ?', environment_id, 'Profile', source.id], :include => :role_assignments, :order => "profiles.id", :offset => offset)
  8 + source.members.first(:order => :id, :offset => offset)
10 9 end
11 10  
12 11 def each_recipient
... ...