Simulating JSON PUT in Rails

I am currently working on a JSON API for a game that is to be launched in February. The game developer and I have decided on it to communicatie between flash and the database for a simple reason: built in in both Rails in Flash. There is one interesting thing though. Flex has no idea what a PUT request is and Rails, in recent versions, won’t let you override with a _method parameter.

You see in Rails, PUT is used when you want to update an existing record. Since browsers don’t do PUT either, this is simulated by sending a _method parameter with value put. But sending this parameter with a JSON request does not work, either in the request uri or the post body. What to do?
You send an X-Http-Method-Override along with the request. The Rack middleware inside Rails picks it up and overrides the request method. It does work and I think it’s a pretty clean method. Your curl debug command line will look like this:

curl
  -H "X-Http-Method-Override: put"
  -H "Content-Type: application/json"
  -d "{\"user\":{\"email\":\"blah@example.com\"}}"
  www.site.com/users/username.json