0
我想在rails action mailer中創建會話變量。雖然試圖創建它給這個錯誤:如何在動作郵件程序中創建rails會話變量?
undefined local variable or method `session'
請幫助,如果有人知道解決方案。
我想在rails action mailer中創建會話變量。雖然試圖創建它給這個錯誤:如何在動作郵件程序中創建rails會話變量?
undefined local variable or method `session'
請幫助,如果有人知道解決方案。
會話變量在郵件程序中無法訪問。
您可以通過將參數作爲參數傳遞來訪問會話變量。
YourMailer.mailer_method(session[:variable])
只是通過current_user
向寄件人method
。郵寄者不應該訪問會話變量,並且您的current_user
方法取決於session variable
。現在
class MyMailer < ActionMailer::Base
def hello_email(user)
@user = user
# your hard stuff code whatever you wanted
end
end
你可以通過這樣的:
MyMailer.hello_email(current_user).deliver
對不起。我錯誤地問了問題。我想在郵件程序中創建會話變量 – 2014-09-22 12:37:07