ruby on rails - How come the the index action renders the show view? -


i've noticed index actions(methods) in controller typically render show view.

so example:

/posts/index  

when on localhost renders show view. while simple

/posts 

renders index. why this? haven't been able find anywhere explains this?

i'm new rails, thanks!

/posts maps route of index action.

/posts/index maps route of show action. you'll error saying cannot find post id=index.

routes generated resource posts follows:

     posts    /posts(.:format)                                              posts#index            post   /posts(.:format)                                              posts#create new_post      /posts/new(.:format)                                          posts#new edit_post    /posts/:id/edit(.:format)                                     posts#edit post         /posts/:id(.:format)                                          posts#show           patch  /posts/:id(.:format)                                          posts#update           put    /posts/:id(.:format)                                          posts#update           delete /posts/:id(.:format)                                          posts#destroy 

rails match path /posts/index 1 of show action i.e. /posts/:id.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -