# Restful routes and Rails Console

**URL:** <https://www.ruby-forum.com/t/restful-routes-and-rails-console/158841>\
**Category:** Rails\
**Created:** [January 28, 2009, 5:10pm UTC](https://www.ruby-forum.com/t/restful-routes-and-rails-console/158841 "2009-01-28T17:10:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [January 28, 2009, 5:10pm UTC](https://www.ruby-forum.com/t/restful-routes-and-rails-console/158841/1 "2009-01-28T17:10:00Z")

</div>

The following is a snippet of the routes.rb file:

map.resources :blogs do |blog|  
blog.resources :posts do |post|  
post.resources :comments  
end  
end

The index action in the CommentsController shows:

redirect\_to comments\_url

I am trying to see what comments\_url resolves to in the Rails Console,  
but do not know how.

Thanks in advance for your time and help.

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [January 28, 2009, 8:10pm UTC](https://www.ruby-forum.com/t/restful-routes-and-rails-console/158841/2 "2009-01-28T20:10:52Z")

</div>

Hi,

On Jan 28, 5:10 pm, Bharat R. wrote:

> I am trying to see what comments\_url resolves to in the Rails Console,  
> but do not know how.

There’s a good reason for this: You don’t use/need urls in your  
console.  
The best way is to write tests for your routes, this will also give  
you the  
most confidence in your own code.

ciao, tom

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [January 28, 2009, 9:04pm UTC](https://www.ruby-forum.com/t/restful-routes-and-rails-console/158841/3 "2009-01-28T21:04:34Z")

</div>

Hi–  
On Jan 28, 2009, at 10:44 AM, Thomas R. Koll wrote:

> console.  
> The best way is to write tests for your routes, this will also give  
> you the  
> most confidence in your own code.

If you want to test routes, shoulda[1] has macros for that. For rspec  
users, that would be carlosbrando-remarkable[2].

If you still want to puch this stuff into console,

> > include ActionController::UrlWriter  
> > new\_session\_path  
> > =\> “/session/new”

See if this helps.

[1] Projects - Shoulda  
[2] carlosbrando’s remarkable at master - GitHub

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [January 28, 2009, 10:12pm UTC](https://www.ruby-forum.com/t/restful-routes-and-rails-console/158841/4 "2009-01-28T22:12:40Z")

</div>

Thank you Steve. This is precisely what I needed.  
Thomas, I appreciate your time as well. It is just that I learn better  
by typing “things” in the Rails Console in bits and pieces and see what  
happens. It is this interactive nature of Ruby and Rails which I like  
very much. Reminds me of the “Immediate Window” in Visual Basic/Access  
which made me very productive.

But I do agree with both you gentlemen that a structured testing  
methodology is better suited for the task.

Regards,

Bharat
