Search code examples
ruby-on-railspaypalruby-on-rails-3.2refinerycms

Default route only for [POST] - Ruby on Rails 3.2


When specifying a return URL for PayPal on my web site, I get the following error:

No route matches [POST] "/"

I would like to specify a default route for the POST method.

How can I make that the default 'root' route accepts also POST requests? Can I specify separate 'root' routes for POST and GET requests?

My route currently looks like this:

root GET / refinery/pages#home

Incidentally I'm using Refinery CMS


Solution

  • Finally what worked for me was a match plus a redirect:

    match "/" => redirect("/"), :via => :post
    

    This converted a POST request to / into a GET request. Otherwise, the request goes to the correct route but it continues to be a POST request and this makes that my session is not loaded. I'm still not sure why a POST request to / doesn't load the original session I had before going to PayPal and coming back.