# ActionView::TemplateError (undefined method \`url\_for'

**URL:** <https://www.ruby-forum.com/t/actionview-templateerror-undefined-method-url-for/49476>\
**Category:** Rails\
**Created:** [December 5, 2005, 5:28am UTC](https://www.ruby-forum.com/t/actionview-templateerror-undefined-method-url-for/49476 "2005-12-05T05:28:15Z")\
**Posts on this page:** 1\
**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 5, 2005, 5:28am UTC](https://www.ruby-forum.com/t/actionview-templateerror-undefined-method-url-for/49476/1 "2005-12-05T05:28:15Z")

</div>

Wow, this is driving me crazy. I keep getting this error:

ActionView::TemplateError (undefined method `url\_for’ for  
#Notifier:0x40755260) on line #0 of  
app/views/notifier/link\_added.rhtml:

Absolutely nowhere in that template (or the ActionMailer) is ‘url\_for’,  
nor any other methods. The  
template just outputs variables. Notifier (an ActionMailer) just assigns  
the vars. In my  
controller I have:

def create  
…  
Notifier::deliver\_link\_added(@site, @link,  
url\_for({:controller=\>‘link’, :action=\>‘edit’,  
:id=\>@link.id}))

redirect\_to({:controller =\> ‘link’, :action =\> ‘added’, :id =\>  
@link.id})  
…  
end

Furthering my insanity, I get one of three different results:

1. Application error with the aforementioned error in the log.
2. Link gets created, but Notifier’s link\_added template gets displayed  
for link#added rather than  
view/link/added.rhtml
3. Everything works fine!

Restarting SCGI usually lets #3 or #2 happen again, but adding  
additional links thereafter usually  
results in #1.

csn

* * *

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