is there a global way I can write a before_filter for my user mailer, that checks to see if the user has emails disabled? Right now every mailer I have checks the user\'s se
I haven't done this, but I've done similar things with an email interceptor.
class MailInterceptor
def self.delivering_email(message)
if User.where( :email => message.to ).first.mail_me != true
message.perform_deliveries = false
end
end
end
You won't have access current_user, so you find the user by email, which should already be in the mail object as the 'to' field.
There's a good Railscast covering setting up email interceptors. http://railscasts.com/episodes/206-action-mailer-in-rails-3?view=asciicast