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.

8 Responses to “Testing Named Routes in the Rails Console”
  1. 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.

  2. Thank you very much, just what I was looking for!

  3. Exactly what I needed, thanks!

  4. Big thanks

  5. Just what i was looking for, thanks :)

  6. Thank you kindly.

  7. nice tip. I’m using it at this very moment

  8. insanedreamer says:

    For those of you who find this and are using Rails3, ActionController::UrlWriter has been deprecated. Instead use:

    include Rails.application.routes.url_helpers

Leave a Reply