3
辅助方法current_user
定义和ApplicationController
提供作为辅助这样的:使用的邮件一个辅助方法是在控制器中定义
class ApplicationController < ActionController::Base
helper_method :current_user
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.record
end
end
我的问题是如何利用current_user
帮手方法在邮件模板中(显然它总是会返回nil
,但我试图渲染一个依赖于它的部分)。
通常当我想在一个邮件使用的助手,我像做add_template_helper(SongsHelper)
,但因为助手在一个类中,而不是一个模块定义我不知道该怎么做
我在一个邮件程序方法参数中传递了控制器方法的返回值。 'UserMailer.invitation(@invitation,current_organization).deliver'其中current_organization在'ApplicationController'中定义 – 2012-08-15 11:10:41