I finally found out how to do this, from the Rails Routing shortcut by David Black. In the Rails console, do this:
include ActionController::UrlWriter default_url_options[:host] = 'whatever'
Then you can call your named route methods directly from the console.
Interesting…but as a side note, I just noticed that the pdf you referenced has been included in The Rails Way book. Just some info for anyone considering purchasing that pdf like I did.
Thank you very much, just what I was looking for!
Exactly what I needed, thanks!
Big thanks
Just what i was looking for, thanks :)
Thank you kindly.
nice tip. I’m using it at this very moment
For those of you who find this and are using Rails3, ActionController::UrlWriter has been deprecated. Instead use:
include Rails.application.routes.url_helpers
[…] Also works for RESTful routes. – Link […]
An even easier way (that still works in Rails3), just call your named route off of app:
app.my_route_name_url(1) #=> “http://http://www.example.com/my_route_name/1”
[…] a useful tip for testing rails routes in your […]
Joshua, that’s even better! Thanks.
Very cool. Now I have a quick way to look at all the automagic paths and urls! Thanks all
#from rails console
app.methods.grep(/(path|url)/).sort
This was a big help! Thanks very much.