# Url\_for in ActionMailer?

**URL:** <https://www.ruby-forum.com/t/url-for-in-actionmailer/51965>\
**Category:** Rails\
**Created:** [December 4, 2005, 5:32am UTC](https://www.ruby-forum.com/t/url-for-in-actionmailer/51965 "2005-12-04T05:32:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [December 4, 2005, 5:32am UTC](https://www.ruby-forum.com/t/url-for-in-actionmailer/51965/1 "2005-12-04T05:32:49Z")

</div>

I’d like to insert a url in an email template. I tried this, but it  
gives an ‘undefined method’  
error (probably because ActionMailer doesn’t derive from  
ActionController or apparently have  
access to the ActionView helpers):

\<%= url\_for :controller=\>‘member’, :action=\>‘show’,  
:username=\>@member.username %\>

Is there a quick and easy workaround?

thanks  
csn

* * *

Yahoo! DSL ? Something to write home about.  
Just $16.99/mo. or less.  
[dsl.yahoo.com](http://dsl.yahoo.com)

---

<div class="post-metadata">

**Author:** ![cool\_screen\_name900](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c68b51/32.png) [@cool\_screen\_name900](https://www.ruby-forum.com/u/cool_screen_name900)\
**Post date:** [December 4, 2005, 3:00pm UTC](https://www.ruby-forum.com/t/url-for-in-actionmailer/51965/2 "2005-12-04T15:00:52Z")

</div>

CSN \<cool\_screen\_name90001@…\> writes:

> I’d like to insert a url in an email template. I tried this, but it gives an  
> ‘undefined method’
> 
> Is there a quick and easy workaround?

Quick and easy? Yes. Satisfying? Definitely not.

Just generate the URL in your controller and pass it to the template as  
a  
parameter. Works fine, but it just isn’t right: it’s so obvious that  
you will  
want to email computed URLs to people that you should be able to do it  
directly.

Rails ticket #1138 ([http://dev.rubyonrails.org/ticket/1138](http://dev.rubyonrails.org/ticket/1138)) is about  
this.

–Forrest
