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