Commit 790373996df1772d432f255c80cc456d9bbf5047
1 parent
37e4ba3e
Exists in
master
and in
29 other branches
Using proper ActiveRecord relationships
All related tests still pass. (ActionItem1659)
Showing
2 changed files
with
2 additions
and
3 deletions
Show diff stats
app/models/environment_mailing.rb
| 1 | class EnvironmentMailing < Mailing | 1 | class EnvironmentMailing < Mailing |
| 2 | 2 | ||
| 3 | def recipient(offset=0) | 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 | end | 5 | end |
| 6 | 6 | ||
| 7 | def each_recipient | 7 | def each_recipient |
app/models/organization_mailing.rb
| @@ -5,8 +5,7 @@ class OrganizationMailing < Mailing | @@ -5,8 +5,7 @@ class OrganizationMailing < Mailing | ||
| 5 | end | 5 | end |
| 6 | 6 | ||
| 7 | def recipient(offset=0) | 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 | end | 9 | end |
| 11 | 10 | ||
| 12 | def each_recipient | 11 | def each_recipient |