Resource helpers in rails console

rest, ruby-on-rails-3

Solution

route helpers are available within the `app` object, so you can get access to them this way

app.photos_path     # => "/photos"

Problem

As given on http://guides.rubyonrails.org/routing.html, creating a resourceful route will also expose a number of helpers to the controllers in the application. For example a resourceful route `resources :photos` will provide helpers like photos_path,new_photo_path etc. Now, i can call a helper in the rails console using the helper object, for example `helper.link_to "this", "that"`. But calling `helper.photos_path` in the rails console does not work,however in the controller those helpers are accessible. Why is this so ? Thank You

Original source