开发者

How can I access @user or user from a mailer using Devise and Rails 3?

开发者 https://www.devze.com 2023-02-15 11:24 出处:网络
class JobMailer < ActionMailer::Base default :from => \"emailer@email.com\" def new_job_email_for_client
class JobMailer < ActionMailer::Base

default :from => "emailer@email.com"

def new_job_email_for_client
#
#
@url = "http://simplesite.com/users/login"
mail(:to => @???,
      :subject => "You have created a new case on simplesite.")
end

end

I would like each user to receive an email each and every time he/she creates a "job." In other parts of the application, I can access @user and user.email and such, but in the m开发者_JAVA百科ailer I'm getting "undefined errors."

How can I access the current users email address in the mailer (taking into consideration that Devise is in control of Users)?


I'm not sure if this is a great way of doing it, but this is how I got it working:

def new_job_email_for_client(user_email)
@url = "http://simplesite.com/users/login"
mail(:to => user_email,
      :subject => "You have created a new case.")
end
0

精彩评论

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