Tyler DeWitt
Tyler DeWitt

Reputation: 23576

Ruby Routes Not Always In Same Order

I have this in my routes.rb file:

resources :carts do
    collection do
      post :review
      post :charge
    end
end

Sometimes, when a user goes to /carts/review, instead of going to the review action, it instead tries to go to show with an id of review. I've gotten this error 3 times in production, and successfully reviewed the cart dozens of times. Any ideas on what might be happening?

This is Rails 3.2.1 running on Ubuntu 10.04 with ruby 1.9.1.

Upvotes: 0

Views: 33

Answers (1)

Chris Heald
Chris Heald

Reputation: 62648

Your routes only accept the POST method for /carts/review. A GET to /carts/review will be interpreted as /carts/:id, :id => "review" because there is no GET path for /carts/review specifically.

Upvotes: 1

Related Questions