Using a helper method in an email program that is defined in the controller

A helper method is current_userdefined and available as a helper in the ApplicationControllerfollowing way:

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 can I use the helper method current_userin the mailer template (obviously, it will always return nil, but I'm trying to do a partial one that depends on it).

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

+3
source share
1 answer

, . current_user ( ).

current_user ApplicationController, helper , ActionMailer:: Base. , .

+4

Source: https://habr.com/ru/post/1745390/


All Articles