Hi, Any idea why image_tag doesn''t work within an email template? I''m trying to generate the URL for an image and I''m getting the following error. undefined method `request'' for #<Mailer:0x6a719e0> I''ve been able to use link_to but no luck with image_tag. I''ve seen a similar post to this in the list but no one has posted a response. build the image tag myself but I would like to keep it neat. Maria -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060804/8f420eeb/attachment.html
"Maria Gutierrez" <gutierrez.maria@gmail.com> writes:> Hi, > > Any idea why image_tag doesn''t work within an email template? I''m trying to > generate the URL for an image and I''m getting the following error. > > undefined method `request'' for #<Mailer:0x6a719e0> > > I''ve been able to use link_to but no luck with image_tag. >Are you sure, when I last checked `link_to'' wasn''t working. Make sure the error is due to image_tag and not link_to. I think, the actionmailer views have access to very limited set of actionview helpers, and emails are not necessarily sent due to controller actions, they can be triggered from models also, because of this reason link_to is not available in email templates, as it requires the request object to get the URL. HTH. -- Surendra Singhi http://ssinghi.kreeti.com, http://www.kreeti.com Read my blog at: http://cuttingtheredtape.blogspot.com/ ,---- | Great wits are sure to madness near allied, | And thin partitions do their bounds divide. | | (John Dryden, Absalom and Achitophel, 1681) `----
Thanks for your reply Surendra. link_to is working for me. The only difference from what you probably tried is that I''m linking to an external url (one of our other applications), something similar to the example below. link_to "Google", "http://www.google.com" I guess in this case there''s no need for the request and that''s why I''ve got it working, probably is you pass url options it will fail in the same way as image_tag. I''ll have to write the image_tag manually. Not as tidy but will do the job. Maria
Try explicitly putting helper :url_helper In your mailer model class. On 8/4/06 3:40 AM, "Maria Gutierrez" <gutierrez.maria@gmail.com> wrote:> Hi, > > Any idea why image_tag doesn''t work within an email template? I''m trying to > generate the URL for an image and I''m getting the following error. > > undefined method `request'' for #<Mailer:0x6a719e0> > > I''ve been able to use link_to but no luck with image_tag. > > I''ve seen a similar post to this in the list but no one has posted a response. > build the image tag myself but I would like to keep it neat. > > Maria > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060804/4d79f80c/attachment.html
On 8/4/06, s.ross <cwdinfo@gmail.com> wrote:> > Try explicitly putting > > helper :url_helper > > In your mailer model class.Ooh, nice. I was having to go into the email views and including ActionSomething::whatever. I''ll try that. Joe> On 8/4/06 3:40 AM, "Maria Gutierrez" <gutierrez.maria@gmail.com> wrote: > > > > Hi, > > Any idea why image_tag doesn''t work within an email template? I''m trying to > generate the URL for an image and I''m getting the following error. > > undefined method `request'' for #<Mailer:0x6a719e0> > > I''ve been able to use link_to but no luck with image_tag. > > I''ve seen a similar post to this in the list but no one has posted a > response. build the image tag myself but I would like to keep it neat. > > Maria > > ________________________________ > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
This didnt work for me. It gave me an error, because it couldnt find it in helpers/url_helper.rb. I dont think it has the right look up directory Joe Van Dyk wrote:> On 8/4/06, s.ross <cwdinfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> Try explicitly putting >> >> helper :url_helper >> >> In your mailer model class. > > Ooh, nice. I was having to go into the email views and including > ActionSomething::whatever. I''ll try that. > > Joe-- 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 -~----------~----~----~----~------~----~------~--~---