# RESTful url not working

**URL:** <https://www.ruby-forum.com/t/restful-url-not-working/153957>\
**Category:** Rails\
**Created:** [November 23, 2008, 11:03pm UTC](https://www.ruby-forum.com/t/restful-url-not-working/153957 "2008-11-23T23:03:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashit\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@Ashit\_V](https://www.ruby-forum.com/u/Ashit_V)\
**Post date:** [November 23, 2008, 11:03pm UTC](https://www.ruby-forum.com/t/restful-url-not-working/153957/1 "2008-11-23T23:03:54Z")

</div>

Hi,  
'm new to Rails.  
I tried using \_path and \_url with link\_to helper method but it doesnt  
work for me.

Does anyone know what can be the issue?  
my code is

# Hello Rails
\<%= flash[:notice] %\> \<%= link\_to 'Show Blog', posts\_url %\>

Post is my controller

The error ‘m getting is  
undefined local variable or method `posts\_url’ for #\<ActionView::Base:  
0x102b23d\>

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Ashit\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@Ashit\_V](https://www.ruby-forum.com/u/Ashit_V)\
**Post date:** [November 23, 2008, 11:52pm UTC](https://www.ruby-forum.com/t/restful-url-not-working/153957/2 "2008-11-23T23:52:32Z")

</div>

Hello Ashit,

If you run “rake routes” in your project directory you’ll see what  
routes are available. Also, the singular vs plural question needs to  
be considered here.

Typically:  
The model has a singular name - models/path.rb  
The controller has a plural name - controllers/paths\_controller.rb  
The view has a plural name - views/paths/edit.html.erb

So a url for your controller would typically be: paths\_url

Rick

---

<div class="post-metadata">

**Author:** ![Ashit\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@Ashit\_V](https://www.ruby-forum.com/u/Ashit_V)\
**Post date:** [November 24, 2008, 2:11am UTC](https://www.ruby-forum.com/t/restful-url-not-working/153957/3 "2008-11-24T02:11:41Z")

</div>

“rake routes” really becomes your friend here as you are able to take  
a look at everything that will work. Trust me, just run it and look  
over the output to see where you might be going wrong.

---

<div class="post-metadata">

**Author:** ![Ashit\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@Ashit\_V](https://www.ruby-forum.com/u/Ashit_V)\
**Post date:** [November 24, 2008, 3:44am UTC](https://www.ruby-forum.com/t/restful-url-not-working/153957/4 "2008-11-24T03:44:03Z")

</div>

Hi Ashit. Another thing that you can do is test out the various URL  
and path helpers in your app’s console. For example:

$ script/console  
Loading development environment (Rails 2.1.0)

> >

?\> app.photos\_url  
=\> “[http://www.example.com/photos](http://www.example.com/photos)”

> >

?\> app.photos\_path  
=\> “/photos”

> >

?\> quit

Cheers,  
Nick

---

<div class="post-metadata">

**Author:** ![Ashit\_V](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@Ashit\_V](https://www.ruby-forum.com/u/Ashit_V)\
**Post date:** [November 24, 2008, 4:31am UTC](https://www.ruby-forum.com/t/restful-url-not-working/153957/5 "2008-11-24T04:31:18Z")

</div>

Nick H. wrote:

> Hi Ashit. Another thing that you can do is test out the various URL  
> and path helpers in your app’s console. For example:
> 
> $ script/console  
> Loading development environment (Rails 2.1.0)
> 
> > >
> 
> ?\> app.photos\_url  
> =\> “[http://www.example.com/photos](http://www.example.com/photos)”
> 
> > >
> 
> ?\> app.photos\_path  
> =\> “/photos”
> 
> > >
> 
> ?\> quit
> 
> Cheers,  
> Nick

good one  
Thanks
