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...
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With