ruby on rails - Is it good practice to send in multiple mail methods in an ActionMailer Model action, or should that logic be kept outside of the Mailer action? -
which preferred?
class mailer < actionmailer::base # this? def bid_end_notify_failed_bidders(job) @job = job bidders = @job.bidders bidders.delete(@job.winner) bidders.each |t| mail(:to => t.email, ....) end end # or this? def notify_failed_bid(bidder) mail(:to => bidder ...) end end
i suggest method #2, because want agile in way send email.
the regular way of using is:
declare instance declare relations need instance pass instances mailer::base method deliverexample:
user = user.first
bets_won = user.bets_won
mailer.send_congrats(users, bets_won).deliver!
now utilize info it's beingness served no logic has done mailer class approach allow reuse method easily.
ruby-on-rails ruby-on-rails-3 coding-style actionmailer
No comments:
Post a Comment