Access helpers from mailer?

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

    A hackish means of achieving what I wanted is to store the objects I need (current_user.name + current_user.email) in thread attributes, like so: Thread.current[:name] = current_user.name. Then in my mailer I just assigned new instance variables to those values stored in the thread: @name = Thread.current[:name]. This works, but it won't work if using something like delayed job.

提交回复
热议问题