views:

38

answers:

1

Coming from rails 2, most of my controllers would have these lines:

verify :method => :post, :only => :create, :render => {:text => '405 HTTP POST required', :status => 405}, :add_headers => {'Allow' => 'POST'}
verify :method => :put, :only => :update, :render => {:text => '405 HTTP PUT required', :status => 405}, :add_headers => {'Allow' => 'PUT'}
verify :method => :delete, :only => :destroy, :render => {:text => '405 HTTP DELETE required', :status => 405}, :add_headers => {'Allow' => 'DELETE'}

After migrating to Rails 3, I get the deprecation warning telling me that these have been removed. I know I can get some plugin or whatever to still use them, but my question is do I really need to anymore? Does rails 3 enforce the basic methods by default? Seems like it should if it doesnt, I always felt annoyed to have to write these lines over and over again...

A: 

You don't need to verify the request method if you use REST routes. The controller action simply won't be reach with the wrong request method.

For example, if you try to reach /users/create?name=my_name through get, the request will reach the show action with the params[:id] = create, and that will fail.

Yannis