Access helpers from mailer?

前端 未结 11 1796
夕颜
夕颜 2020-12-05 17:25

I have trying to access helper methods from a rails 3 mailer in order to access the current user for the session.

I put the helper :application in my mailer class,

11条回答
  •  一整个雨季
    2020-12-05 17:30

    The single method version of promoting a method to being a helper that is available in ApplicationController also works in ActionMailer:

    class ApplicationMailer < ActionMailer::Base
      helper_method :marketing_host
    
      def marketing_host
        "marketing.yoursite.com"
      end
    end
    

    from there you can call marketing_host from any of your mailer views

提交回复
热议问题