So I'm new to grape, and was putting together a backbone app with a
grape backend. GET requests cause me no grief, but I can't get a PUT
request to work to save my life.
The code is here:
https://github.com/knewter/grape_demo. The app is
at /winelist.html
Anyway, I have this bit of code setting up the put request in my api:
desc "Update a wine"
put ':id' do
wine = Wine.find(id)
wine.update_attributes(params)
wine
end
I can see that the route exists:
ruby-1.9.2-p290 :002 > Acme::API.routes
=> [version=v1, method=GET, path=/api/:version/wines(.:format),
version=v1, method=GET, path=/api/:version/wines/:id(.:format),
version=v1, method=PUT, path=/api/:version/wines/:id(.:format)]
But when I PUT to that route, I get a 405 Method Not Allowed:
"NetworkError: 405 Method Not Allowed -
http://localhost:9292/api/v1/wines/4f3fb4423aa9dc766a000001"
The grape log looks like this:
127.0.0.1 - - [19/Feb/2012 07:26:15] "PUT /api/v1/wines/
4f3fb4423aa9dc766a000001 HTTP/1.1" 405 19 0.0010
Anyway, I've spent like 3 hours trying to get past this (got to this
point very quickly, can't seem to get past it) so I figured it was
time to seek outside help. I've tried it in webrick, thin, and
unicorn. I grepped the grape codebase for 405 and it doesn't exist in
it. All of the grape tests pass for the SHA hash I'm on. Help?
Thanks...