I’m trying to post data to a certain controller#action pair, but my app redirects me on POST (but not GET), and I can’t figure out why.
I built a bare-bones controller with one method:
class NavigationsController < ApplicationController
def foo
render :text => 'in foo'
end
end
My routing file has only one rule:
map.connect ':controller/:action/:id'
Here’s my result when I GET and POST, though:
$ curl http://localhost:3000/navigations/foo/1
in foo
$ curl -d 'a=b' http://localhost:3000/navigations/foo/1
<html><body>You are being <a href="http://localhost:3000/">redirected</a>.</body></html>
specs: rails 2.3.8, ruby 1.8.7
Turn off
protect_from_forgery.For all controllers
Commenting out (or delete)
protect_from_forgeryin ApplicationController.For one or more controllers
Add
skip_before_filter :verify_authenticity_tokento the controller declaration.For one or more actions
Add an
:exceptoption to the foregoingskip_before_filterorprotect_from_forgerycommands.