diff options
-rw-r--r-- | app/models/user_mailer.rb | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb index 7379e5d..db60b86 100644 --- a/app/models/user_mailer.rb +++ b/app/models/user_mailer.rb @@ -1,9 +1,10 @@ class UserMailer < ActionMailer::Base - def common(user) + def common(user, subject) @recipients = user.email_address @from = "no-reply@#{ ActionMailer::Base.default_url_options[:host] }" @sent_on = Time.now @headers = {} + @subject = subject end def question_title(answer) @@ -11,35 +12,30 @@ class UserMailer < ActionMailer::Base end def forgot_password(user, key) - common(user) - @subject = "#{@app_name} -- forgotten password" - @body = { :user => user, :key => key, :app_name => app_name } + common(user, "#{@app_name} -- forgotten password") + @body = { :user => user, :key => key, :app_name => app_name } end def new_question(user, question) - common(user) - @subject = "New question" - @body = { :title=> question.title, :category => question.question_category, + common(user, "New question") + @body = { :title=> question.title, :category => question.question_category, :id => question.id} end def new_answer(user, answer) - common(user) - @subject = "New answer" - @body = { :question_title=> question_title(answer), :recruit_name => + common(user, "New answer") + @body = { :question_title=> question_title(answer), :recruit_name => answer.owner.name, :id => answer.id} end def changed_answer(user, answer) - common(user) - @subject = "Changed answer" - @body = { :question_title=> question_title(answer), :recruit_name => + common(user, "Changed answer") + @body = { :question_title=> question_title(answer), :recruit_name => answer.owner.name, :id => answer.id} end def new_comment(user, comment) - common(user) - @subject = "New comment" - @body = { :question_title=> question_title(comment.answer), :id => comment.answer.id } + common(user, "New comment") + @body = { :question_title=> question_title(comment.answer), :id => comment.answer.id } end end |