views:

63

answers:

1

I'm using FLEX 3 to make XML request to Rails 3. Since FLEX 3 only offers POST and GET, I have to use the "?_method=PUT" hack to maintain proper RESTfulness:

http://127.0.0.1:3000/locator/locator_users/1.xml?_method=PUT

On the server side its showing up as a POST and I'm getting an ActionController::RoutingError (No Route Matches).

I did a rake routes and the route is there, properly namespaced and all. This worked fine with Rails 2, so I have reason to believe it must be Rails 3 that changed. After doing some searching, people seemed to have indicated that it should still work. But, it's not for me. Can anyone confirm or deny Rails 3 compatibility?

UPDATE

OK, after some more tinkering, I think this is actually a problem of Flash Player 10. Flash PLayer 9 seems to work fine with "_method=" hack, 10 does not. See this new post I wrote (http://stackoverflow.com/questions/3741212/flash-player-9-vs-flash-player-10-with-flex-3-methodput-delete-not-working).

A: 

Partly this is due to Rack::MethodOverride's behavior. It does not check the query params for _method, so a call to http://127.0.0.1:3000/locator/locator_users/1.xml?_method=PUT will not get overridden properly due to that.

I wrote a piece of Rack middleware that replaces it to fix this particular issue.

All you have to do is add it to the Gemfile

gem 'rack-methodoverride-with-params'

swap Rack::MethodOverride out in config/environment.rb

config.middleware.swap Rack::MethodOverride, Rack::MethodOverrideWithParams
BaroqueBobcat
Wow, thank you. I thought I was going insane... I was blaming Rails 3 and Flash Player and Flex 4... This makes sense, but I cant believe they would leave this out with the move to Rack? Seems like this should definitely be part of the MethodOverride by default... but then again, what do I know?
Buddy
there is a ticket open about it on Rails' lighthouse https://rails.lighthouseapp.com/projects/8994/tickets/2289-_methodput-ignored-for-xhr-and-xml-requests
BaroqueBobcat