Hi all
I have some methods in application.rb and make them accessible to view using
helper_method :xxx
Sadly they don't seem to be available in mailer templates? Is that normal? Or did I miss something?
Thanks Josh
Hi all
I have some methods in application.rb and make them accessible to view using
helper_method :xxx
Sadly they don't seem to be available in mailer templates? Is that normal? Or did I miss something?
Thanks Josh
Hi all
I have some methods in application.rb and make them accessible to view using
helper_method :xxx
Sadly they don't seem to be available in mailer templates? Is that normal? Or did I miss something?
That's normal. ActionMailer classes don't inherit from
ApplicationController so it is normal that the methods in there do not
magically appear in ActionMailer instances/views.
Fred
Frederick Cheung wrote:
Frederick Cheung wrote:
> That's normal. ActionMailer classes don't inherit from > ApplicationController so it is normal that the methods in there do not > magically appear in ActionMailer instances/views.
> Fred
Thanks for your reply. But this seems a little bit strange to me... All in all a view is a view, whether it's a "normal" or a mailer's one, right?
You're right, it's mostly an infratructure problem here. You just can't steal methods defined in a completely separate place.
So what can I do to access my helpers in the mailer's view?
One way would be to define them in a module which you include in ApplicationController and in the mailer (Use the helper method in the latter).
Fred
Frederick Cheung wrote:
Actually, I'm mistaken. I didn't read the post properly.
You use include if you want it available in the class itself, then helper :helper_name if you want it available in the views.
Ramon Tayag