Rails URL helpers in the rails console

Not a day goes by that I don’t find another thing in Rails that delights me and makes life easier. Yesterday it was finding that you can access the Rails application from the rails console by simply calling app:

This returns the entire app instance with all of its methods available to call directly. So helpers you can call in the controller context, you can call on the console as messages to app:

irb(main):190:0> app.manage_posts_path
=> "/manage/posts"
Advertisements