Image_tag + ActionMailer

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

“Maria Gutierrez” [email protected]
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 S.
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

On 8/4/06, s.ross [email protected] 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

Try explicitly putting

helper :url_helper

In your mailer model class.

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 D. wrote:

On 8/4/06, s.ross [email protected] 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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs