Sha256: 3db3f0744c6c85c614d16c2dfb8a3e8427b3d1e9756834aeab37118da246e757
Contents?: true
Size: 1.54 KB
Versions: 21
Compression:
Stored size: 1.54 KB
Contents
class DeviseMailer < ::ActionMailer::Base # Sets who is sending the e-mail def self.sender=(value) @@sender = value end # Reads who is sending the e-mail def self.sender @@sender end self.sender = nil # Deliver confirmation instructions when the user is created or its email is # updated, and also when confirmation is manually requested def confirmation_instructions(record) setup_mail(record, :confirmation_instructions) end # Deliver reset password instructions when manually requested def reset_password_instructions(record) setup_mail(record, :reset_password_instructions) end private # Configure default email options def setup_mail(record, key) mapping = Devise.mappings.values.find { |m| m.to == record.class } raise "Invalid devise resource #{record}" unless mapping subject translate(mapping, key) from self.class.sender recipients record.email sent_on Time.now content_type 'text/html' body mapping.name => record, :resource => record end # Setup subject namespaced by model. It means you're able to setup your # messages using specific resource scope, or provide a default one. # Example (i18n locale file): # # en: # devise: # mailer: # confirmation_instructions: '...' # user: # confirmation_instructions: '...' def translate(mapping, key) I18n.t(:"#{mapping.name}.#{key}", :scope => [:devise, :mailer], :default => key) end end
Version data entries
21 entries across 21 versions & 3 rubygems