Using a helper method in a mailer that is defined in a controller

Posted by Horace Loeb on Stack Overflow See other posts from Stack Overflow or by Horace Loeb
Published on 2010-05-14T02:36:06Z Indexed on 2010/05/14 2:44 UTC
Read the original article Hit count: 381

Filed under:
|
|

The helper method current_user is defined and made available as a helper in ApplicationController like this:

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

My question is how I can use the current_user helper method in a mailer template (obviously it will always return nil, but I'm trying to render a partial that depends on it).

Normally when I want to use helpers in a mailer, I do something like add_template_helper(SongsHelper), but since the helper is defined in a class instead of a module I'm not sure what to do

© Stack Overflow or respective owner

Related posts about ruby

Related posts about ruby-on-rails