Sha256: 039768ad00974f9826ffe01fd332521f3aa97d382c7e60d51fa563f80a6cf8ee

Contents?: true

Size: 979 Bytes

Versions: 4

Compression:

Stored size: 979 Bytes

Contents

class IuguMailer < Devise::Mailer

  default from: "iugu <do-not-respond@iugu.com>",
          reply_to: "iugu <do-not-respond@iugu.com>"

  def template_paths
    "iugu/mailer"
  end

  def reset_password_instructions(record, opts={})
    set_locale(record)
    super(record)
    set_default_locale
  end

  def invitation(user_invitation)
    set_locale(user)
    @user_invitation = user_invitation
    mail(to: @user_invitation.email, :subject => I18n.t("user_invitation")) do |format|
      format.html { render "iugu/mailer/invitation" }
    end
    set_default_locale
  end

  def welcome(user)
    set_locale(user)
    @user = user
    mail(to: @user.email, :subject => I18n.t("user_welcome")) do |format|
      format.html { render "iugu/mailer/welcome" }
    end
    set_default_locale
  end

  private

  def set_locale(user)  
    @default_locale = I18n.locale 
    I18n.locale = user.locale
  end

  def set_default_locale
    I18n.locale = @default_locale
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
iugusdk-1.0.0.alpha.20 app/mailers/iugu_mailer.rb
iugusdk-1.0.0.alpha.19 app/mailers/iugu_mailer.rb
iugusdk-1.0.0.alpha.18 app/mailers/iugu_mailer.rb
iugusdk-1.0.0.alpha.17 app/mailers/iugu_mailer.rb