Commit dbd051c349552b528cd8fa1773fe729650497fac
1 parent
d8b37cde
Exists in
master
and in
29 other branches
Store id's instead of entire ActiveRecord objects
(ActionItem1640)
Showing
2 changed files
with
9 additions
and
3 deletions
Show diff stats
app/controllers/public/invite_controller.rb
| ... | ... | @@ -21,7 +21,7 @@ class InviteController < PublicController |
| 21 | 21 | if !params[:mail_template].match(/<url>/) |
| 22 | 22 | flash.now[:notice] = _('<url> is needed in invitation mail.') |
| 23 | 23 | elsif !contacts_to_invite.empty? |
| 24 | - Delayed::Job.enqueue InvitationJob.new(current_user.person, contacts_to_invite, params[:mail_template], profile) | |
| 24 | + Delayed::Job.enqueue InvitationJob.new(user.id, contacts_to_invite, params[:mail_template], profile.id) | |
| 25 | 25 | session[:notice] = _('Your invitations are being sent.') |
| 26 | 26 | if profile.person? |
| 27 | 27 | redirect_to :controller => 'friends' | ... | ... |
lib/invitation_job.rb
| 1 | -class InvitationJob < Struct.new(:person, :contacts_to_invite, :message, :profile) | |
| 1 | +class InvitationJob < Struct.new(:person_id, :contacts_to_invite, :message, :profile_id) | |
| 2 | 2 | def perform |
| 3 | - Invitation.invite(person, contacts_to_invite, message, profile) | |
| 3 | + begin | |
| 4 | + person = Person.find(person_id) | |
| 5 | + profile = Profile.find(profile_id) | |
| 6 | + Invitation.invite(person, contacts_to_invite, message, profile) | |
| 7 | + rescue ActiveRecord::NotFound => e | |
| 8 | + # ... | |
| 9 | + end | |
| 4 | 10 | end |
| 5 | 11 | end | ... | ... |