El 28/11/2006, a las 14:59, Rob Nichols escribió:>
> I am new to ActionMailer and having a problem.
>
> I want to be able to send a notification e-mail when a new item is
> added
> to a list. Sending an e-mail to the right people on creation is
> working
> fine.
>
> However, I want to include in the e-mail a link to the application so
> that users can click on the link in the e-mail and immediately be
> taken
> to the show view for the new item. When I add a link_to element to the
> e-mail template, I get the error message:
>
> undefined method `url_for'' for #<JobRequestMailer:0x77fe458>
>
> I have tried adding a link to the application helper to the mailer
> model:
>
> helper :application
>
> but that doesn''t seem to have helped.
>
> Can some one either tell me how to access an ActionView method from
> within an ActionMailer object, or provide another work around.
>
> I know I could construct the anchor manually, but then I''ll need
to
> rewrite it if the application moves.
>
That is exactly the point. link_to and url_for construct the url by
knowing the hostname of the request. ActionMailer can''t know this
unless you pass the url. You may want to build the url in the
controller and pass the url to the deliver function.
If you are calling the mailer from a cron job you will have to put a
fixed hostname, since it can''t guess it with no request
object.> --
> Posted via http://www.ruby-forum.com/.
>
> >
--
Jorge Bernal Ordovás <koke-LHjXKMxSopRAfugRpC6u6w@public.gmane.org>
http://amedias.org/ [ES]
http://koke.amedias.org/ [EN]
Warp Networks http://www.warp.es/
María de Luna 11, 50018 Zaragoza, España
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---