Rails 4: before_filter and after_filter in your Mailers
Did you know that you can use filters in your mailers in Rails 4?
I thought it was a such a cool hidden feature.
Here is what you could possibly do in your mailer's after_filter for example.
class UserMailer < ActionMailer
after_filter :stop_delivery
def thismail(user,..)
@user = user
...
end
def thatmail(user,..)
@user = user
...
end
private
def stop_delivery
mail.perform_deliveries = @user.confirmed?
true
end
end
Written by Aditya Sanghi
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Rails
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#