开发者

ActionMailer help, paste email from session!

开发者 https://www.devze.com 2023-03-14 15:12 出处:网络
Notifier.rb class Notifier < ActionMailer::Base def inquiry_notification(inquiry) recipi开发者_开发百科entsinquiry.respondent.email

Notifier.rb

class Notifier < ActionMailer::Base
  def inquiry_notification(inquiry)
     recipi开发者_开发百科ents     inquiry.respondent.email
     from           "#{@laz.email}"
     subject        "Survey"
     content_type "text/html"
  end
end

Part of Controller.rb

...
 @laz = User.find(:all)

        respondents.each do |r|
          inquiry = Inquiry.create(:question_id => @question.id, :respondent_id => r.id, :is_answered => 0)
          Notifier.deliver_inquiry_notification(inquiry)  
        end
....

I need to paste into "FROM" (notifier.rb) email that user has.

For example: session[:user].email <- paste this , because i work with sessions and i have many users (admins and auditors).


Why dont you just add additional parameter to your inquiry_notification method like this:

def inquiry_notification(inquiry, from_email)
  recipients   inquiry.respondent.email
  from         from_email
  subject      "Survey"
  content_type "text/html"
end

If you dont want to do so, you can use for example Thread.current: in controller

Thread.current[:email] = 'test@email.com'

in Notifier

def inquiry_notification(inquiry)
  recipients     inquiry.respondent.email
  from           Thread.current[:email]
  subject        "Survey"
  content_type "text/html"
end
0

精彩评论

暂无评论...
验证码 换一张
取 消