Sha256: f07923493d8750a69ceb6f67aedb45863c06c07b3c543f3f8d22eab30f59b770

Contents?: true

Size: 1.14 KB

Versions: 17

Compression:

Stored size: 1.14 KB

Contents

class IuguMailer < Devise::Mailer

  default from: "Iugu <no-reply@iugu.com>",
          reply_to: "Iugu <no-reply@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)
    user = User.find(user_invitation.invited_by)
    set_locale(user)
    @user_invitation = user_invitation
    @account = @user_invitation.account
    mail(to: @user_invitation.email, :subject => I18n.t("emails.user_invitation", account_name: @user_invitation.account.try(:name))) 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("emails.user_welcome", application_title: IuguSDK::application_title)) 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

17 entries across 17 versions & 1 rubygems

Version Path
iugusdk-1.0.11 app/mailers/iugu_mailer.rb
iugusdk-1.0.10 app/mailers/iugu_mailer.rb
iugusdk-1.0.9 app/mailers/iugu_mailer.rb
iugusdk-1.0.8 app/mailers/iugu_mailer.rb
iugusdk-1.0.7 app/mailers/iugu_mailer.rb
iugusdk-1.0.6 app/mailers/iugu_mailer.rb
iugusdk-1.0.5 app/mailers/iugu_mailer.rb
iugusdk-1.0.4 app/mailers/iugu_mailer.rb
iugusdk-1.0.3 app/mailers/iugu_mailer.rb
iugusdk-1.0.2 app/mailers/iugu_mailer.rb
iugusdk-1.0.1 app/mailers/iugu_mailer.rb
iugusdk-1.0.0.alpha.32 app/mailers/iugu_mailer.rb
iugusdk-1.0.0.alpha.31 app/mailers/iugu_mailer.rb
iugusdk-1.0.0.alpha.30 app/mailers/iugu_mailer.rb
iugusdk-1.0.0.alpha.29 app/mailers/iugu_mailer.rb
iugusdk-1.0.0.alpha.28 app/mailers/iugu_mailer.rb
iugusdk-1.0.0.alpha.27 app/mailers/iugu_mailer.rb