I'm currently following the Shovell tutorial in the Simply Rails 2 book. On page 168, it mentions URL Helpers for the Story Resource
:
stories_path /stories
new_story_path /stories/new
story_path(@story) /stories/1
edit_story_path(@story) /stories/1/edit
The above is then used in the controller:
def create
@story = Story.new(params[:story])
@story.save
redirect_to stories_path
end
My routes.rb
:
ActionController::Routing::Routes.draw do |map|
map.resources :stories
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
It looks like stories_path
is the url name to /stories
. Is that explicitly defined somewhere within my app, I can't seem to grep for that keyword. If not, is there a way that I can check the mapping above from the Rails console or somewhere else? In Django, url names are usually explicitly defined in urls.py
, I just can't figure out how the above is being generated. Any documentation and pointers will help.