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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Oct-23 02:12 UTC
Re: application helper methods in mailers not available?
On 22 Oct 2008, at 14:20, Joshua Muheim wrote:> > 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> Thanks > Josh > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Joshua Muheim
2008-Oct-23 06:58 UTC
Re: application helper methods in mailers not available?
Frederick Cheung wrote:> On 22 Oct 2008, at 14:20, Joshua Muheim 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. > > FredThanks 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? So what can I do to access my helpers in the mailer''s view? Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Oct-23 14:04 UTC
Re: application helper methods in mailers not available?
On Oct 23, 2:58 am, Joshua Muheim <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > On 22 Oct 2008, at 14:20, Joshua Muheim 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> > Thanks > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Joshua Muheim
2008-Oct-24 21:35 UTC
Re: application helper methods in mailers not available?
Frederick Cheung wrote:> On Oct 23, 2:58�am, Joshua Muheim <rails-mailing-l...@andreas-s.net> > wrote: >> 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). > > FredThanks for the idea. Where should I put the module? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ramon Tayag
2009-Oct-25 16:19 UTC
Re: application helper methods in mailers not available?
It seems helper :helper_name doesn''t work anymore (2.3.4) You can use include instead: class Mailer < AM::Base include CoolHelper .... end Al Iv wrote:> Just include in your mailer model > > helper :application > > for example: > class MessageMailer < ActionMailer::Base > > helper :application > > def sent(message) > ... > end > end > On Oct 25 2008, 12:35�am, Joshua Muheim <rails-mailing-l...@andreas--- Posted via http://www.ruby-forum.com/.
Ramon Tayag
2009-Oct-25 16:25 UTC
Re: application helper methods in mailers not available?
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 On Mon, Oct 26, 2009 at 12:19 AM, Ramon Tayag <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > It seems helper :helper_name doesn''t work anymore (2.3.4) > > You can use include instead: > > class Mailer < AM::Base > include CoolHelper > .... > end