Access helpers from mailer?

前端 未结 11 1827
夕颜
夕颜 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:26

    This is a very old question, but I don't see the full answer, so I will try as I didn't find another resource.

    It depends on what you are doing with the methods that have been defined in the helper module. If they are class methods, and everything that's not called on a specific instance seem to be a class methods for 3.2.13, you need to use

    extend ApplicationHelper
    

    if an instance methods

    include ApplicationHelper
    

    and if you want to use them in a mailer view

    helper ApplicationHelper
    

提交回复
热议问题