我正在使用我的Rails 4應用程序的設計。Devise Rails&Admin_Mailer
我在user.rb
模型如下:
def send_admin_mail
AdminMailer.new_user_waiting_for_approval(self).deliver
end
def send_user_welcome_mail
AdminMailer.new_user_waiting_for_access(user).deliver
end
第一種方法向我發送電子郵件時,一個新的用戶註冊。目的是爲第二種方法發送歡迎電子郵件給新用戶。第一種方法有效。第二個提出'no_method_error'的問題(在我的回調控制器中未定義的方法電子郵件)。
我的回調控制器有以下幾點:
def linkedin
@user = User.find_for_linkedin_oauth(request.env["omniauth.auth"])
if @user.persisted?
@user.send_admin_mail
@user.send_user_welcome_mail
redirect_to root_path, :event => :authentication
# sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
# set_flash_message(:notice, :success, :kind => "LinkedIn") if is_navigational_format?
else
session["devise.linkedin_data"] = request.env["omniauth.auth"]
redirect_to root_path
end
end
我admin_mailer有:
def new_user_waiting_for_approval(user)
@user = user
mail(to: "[email protected]", from: "[email protected]",
subject: "Registration Request #{user.first_name} #{user.last_name} <#{user.email}>")
end
def new_user_waiting_for_access(user)
@user = user
mail(to: user.email, from: "[email protected]", subject: "Welcome to Co #{user.first_name}")
end
我不知道我是否需要CURRENT_USER更換用戶利用色器件的方法也許在第二個方法中,是否需要在{}和/或「」上使用user.email的變體?我嘗試了幾種不同的變化和組合,但沒有取得任何成功。
謝謝你的幫助。
你能後你得到 – pshoukry 2014-12-06 22:46:25