From 72d1fe45723ee9a586679fd2b62481389ca99fbc Mon Sep 17 00:00:00 2001 From: "Carlos A. da Silva" Date: Thu, 8 Oct 2009 11:40:53 -0300 Subject: [PATCH] Refactoring notifier and adding locale translation. --- app/models/notifier.rb | 31 +++++++++++++++++++------------ config/locales/en.yml | 3 +++ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/models/notifier.rb b/app/models/notifier.rb index 1f46af98..077ea87c 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -1,21 +1,28 @@ class Notifier < ::ActionMailer::Base cattr_accessor :sender + # Deliver confirmation instructions when the user is created or confirmation + # is manually requested + # def confirmation_instructions(record) - from self.class.sender - recipients record.email - subject I18n.t(:confirmation_instructions, :scope => [:devise, :notifier], :default => 'Confirmation instructions') - sent_on Time.now - content_type 'text/html' - body record.class.name.downcase.to_sym => record + subject I18n.t(:confirmation_instructions, :scope => [:devise, :notifier], :default => 'Confirmation instructions') + setup_mail(record) end + # Deliver reset password instructions when manually requested + # def reset_password_instructions(record) - from self.class.sender - recipients record.email - subject I18n.t(:reset_password_instructions, :scope => [:devise, :notifier], :default => 'Reset password instructions') - sent_on Time.now - content_type 'text/html' - body record.class.name.downcase.to_sym => record + subject I18n.t(:reset_password_instructions, :scope => [:devise, :notifier], :default => 'Reset password instructions') + setup_mail(record) end + + private + + def setup_mail(record) + from self.class.sender + recipients record.email + sent_on Time.now + content_type 'text/html' + body record.class.name.downcase.to_sym => record + end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 371c8d33..11a76f4e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -8,4 +8,7 @@ en: confirmation: send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.' confirm: 'Your account was successfully confirmed!' + notifier: + confirmation_instructions: 'Confirmation instructions' + reset_password_instructions: 'Reset password instructions'