Skip to content

Instantly share code, notes, and snippets.

@gschorkopf
Created December 13, 2013 18:03
Show Gist options
  • Save gschorkopf/7948462 to your computer and use it in GitHub Desktop.
Save gschorkopf/7948462 to your computer and use it in GitHub Desktop.
Orders controller -> Worker -> Mailer
# Version 1:
def perform(order_attributes, user_attributes, order_total)
UserMailer.order_confirmation(order_attributes, user_attributes, order_total).deliver
end
def order_confirmation(user_attributes, order_attributes, order_total)
@user = user_attributes
@order = order_attributes
@total = order_total
@url2 = 'http://fourth-meal.herokuapp.com'
mail(to: @user[:email],
subject: 'Thank you for your order!')
end
# Version 2:
def perform(order_id, user_id)
UserMailer.order_confirmation(order_id, user_id).deliver
end
def order_confirmation(order_id, user_id)
@user = User.find(user_id)
@order = Order.find(order_id)
mail(to @user.email, subject: "Thank you for your order!")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment