ヘルパー メソッド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)
が、ヘルパーはモジュールではなくクラスで定義されているため、どうすればよいかわかりません