Arjun
Arjun

Reputation: 1711

Rails POST requests

I am new to Rails and we are using version 2.3.5 running on Heroku.

In my routes.rb file I have the defaults:

map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'

GET requests to the expected urls work, however POST request do not seem to be routed to these URLs. I've tried the rails docs, but they seem only to be for version 3.0.0.

How do I get both POST and GET requests to the appropriate urls?

Thanks

Upvotes: 0

Views: 251

Answers (2)

jmontross
jmontross

Reputation: 3581

map.connect ':controller/:action/:id'

I think that this would make it so you may post to ':controller/:action/:id/new' as rails default makes the routes restful for your resources. From the command line within your application try running one of the following commands (depending on if you use bundler) and you will see all the available routes along with the http methods.

rake routes

bundle exec rake routes

Upvotes: 0

BananaNeil
BananaNeil

Reputation: 10762

I think this is what you're looking for..

map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
map.connect ':controller/:action/:id', :conditions => { :method => :post }
map.connect ':controller/:action/:id.:format', :conditions => { :method => :post }

Upvotes: 3

Related Questions