how does rails differentiate the method for the same url

Hi:

This is a cross post at stackoverflow, since I do not get the preferred answer,so I post to this list.

Hi:

This is a cross post at
stackoverflow<http://stackoverflow.com/questions/10059550/how-does-rails-differenti…>,
since I do not get the preferred answer,so I post to this list.

--------------------------------------------------------------------------- ----------

I am new in rails,and I create the first rails application (Blog) follow
the guide at rails's
docs<http://guides.rubyonrails.org/getting_started.html>step by step.

However when I run the application,I found something I can not understand.

http://localhost:3000/posts/2

With GET method,this will return the details of post whose id is 2.

But when update this post,I found the action of the form is '/posts/2'.

When delete the post,I found rails create a form element in the body with
action '/posts/2' and method POST,so I wonder how does rails know update or
delete this post?

Since I do not found any condition word in the post controller.
But for path /posts/2,the verbs is POST,both the path and verb are the
same. How does rails know to delete or update the post 2?

Because browsers don't commonly support methods such as PUT, DELETE
etc. these are emulated by having a hidden field in the form called
_method. The rails routing engine extracts this and uses this
overridden method to route the request

Fred