Skip to content

Instantly share code, notes, and snippets.

@iamnader
Created December 9, 2010 21:56
Show Gist options
  • Save iamnader/735395 to your computer and use it in GitHub Desktop.
Save iamnader/735395 to your computer and use it in GitHub Desktop.
# in /config/devise.rb
...
# Configure the class responsible to send e-mails.
#config.mailer = "Devise::Mailer"
config.mailer = "MailerWithInfo"
...
# in /lib
class MailerInfo
def self.attributes=(attributes={})
Thread.current[:mailer_params] = attributes
end
def self.attributes
Thread.current[:mailer_params]
end
end
# in /app/mailers
class MailerWithInfo < Devise::Mailer
def setup_mail(record, action)
atts = MailerInfo.attributes
atts.each {|k,v| instance_variable_set("@#{k}", v) } if atts && atts.is_a?(Hash)
super
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment