From 329cee555928ed9b841812b623b8f4361d1ad937 Mon Sep 17 00:00:00 2001 From: Jens Kraemer Date: Mon, 8 Mar 2010 11:53:08 +0100 Subject: [PATCH] fix mailer --- .../clearance/passwords_controller.rb | 2 +- .../clearance/sessions_controller.rb | 2 +- app/mailers/clearance_mailer.rb | 23 ++++++++----------- lib/clearance/user.rb | 2 +- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/controllers/clearance/passwords_controller.rb b/app/controllers/clearance/passwords_controller.rb index 289355c6f..26de4e978 100644 --- a/app/controllers/clearance/passwords_controller.rb +++ b/app/controllers/clearance/passwords_controller.rb @@ -13,7 +13,7 @@ def new def create if user = ::User.find_by_email(params[:password][:email]) user.forgot_password! - ::ClearanceMailer.deliver_change_password user + ::ClearanceMailer.change_password(user).deliver flash_notice_after_create redirect_to(url_after_create) else diff --git a/app/controllers/clearance/sessions_controller.rb b/app/controllers/clearance/sessions_controller.rb index 41bffa533..640a46ccb 100644 --- a/app/controllers/clearance/sessions_controller.rb +++ b/app/controllers/clearance/sessions_controller.rb @@ -21,7 +21,7 @@ def create flash_success_after_create redirect_back_or(url_after_create) else - ::ClearanceMailer.deliver_confirmation(@user) + ::ClearanceMailer.confirmation(user).deliver flash_notice_after_create redirect_to(sign_in_url) end diff --git a/app/mailers/clearance_mailer.rb b/app/mailers/clearance_mailer.rb index 394df2eb6..131f69919 100644 --- a/app/mailers/clearance_mailer.rb +++ b/app/mailers/clearance_mailer.rb @@ -1,21 +1,18 @@ class ClearanceMailer < ActionMailer::Base - + self.default :from => Clearance.configuration.mailer_sender + def change_password(user) - from Clearance.configuration.mailer_sender - recipients user.email - subject I18n.t(:change_password, - :scope => [:clearance, :models, :clearance_mailer], - :default => "Change your password") - body :user => user + @user = user + mail :to => user.email, :subject => I18n.t(:change_password, + :scope => [:clearance, :models, :clearance_mailer], + :default => "Change your password") end def confirmation(user) - from Clearance.configuration.mailer_sender - recipients user.email - subject I18n.t(:confirmation, - :scope => [:clearance, :models, :clearance_mailer], - :default => "Account confirmation") - body :user => user + @user = user + mail :to => user.email, :subject => I18n.t(:confirmation, + :scope => [:clearance, :models, :clearance_mailer], + :default => "Account confirmation") end end diff --git a/lib/clearance/user.rb b/lib/clearance/user.rb index d6edf313e..6a58d87c7 100644 --- a/lib/clearance/user.rb +++ b/lib/clearance/user.rb @@ -190,7 +190,7 @@ def password_required? end def send_confirmation_email - ClearanceMailer.deliver_confirmation self + ClearanceMailer.confirmation(self).deliver end end