Skip to content

Instantly share code, notes, and snippets.

@hoasung01
Last active August 20, 2019 04:32
Show Gist options
  • Save hoasung01/77f666e928356162c9d76a4d3b58b37e to your computer and use it in GitHub Desktop.
Save hoasung01/77f666e928356162c9d76a4d3b58b37e to your computer and use it in GitHub Desktop.
[code_smells] - callback
# source: ruby science ebook
# app/models/survey_inviter.rb
def deliver_invitations recipients.map do |recipient_email|
Invitation.create!(
survey: survey,
sender: sender,
recipient_email: recipient_email,
status: 'pending',
message: @message
)
end
end
# app/models/invitation.rb
after_create :deliver
# app/models/invitation.rb
def deliver
Mailer.invitation_notification(self).deliver
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment