Search code examples
ruby-on-railsrubyroutesruby-on-rails-2

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


Solution

  • 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 }