RESTful routing in 2.3 breaks

Dear all,

After the release of 2.3 I immediately updated my app. However routing
does no longer seem to work for me. I have no idea how this can happen
but as soon as I POST to, for example, the forums_path, the request
gets routed to ForumsController#index instead of
ForumsController#create. The same happens with nested resources. Eg
POST to forums/1/topics leads to a POST in the ForumsController#1 with
params “id” => “topics”

I’m using these plugins which might mess up the routing:
acts_as_list
ar_fixtures
attachment_fu_hacks
mimetype-fu
restful_authentication
smurf
acts_as_tree
attachment_fu
hoptoad_notifier
newrelic_rpm
role_requirement

Any help would be great.

Harm

On Tue, Mar 17, 2009 at 1:27 AM, harm [email protected] wrote:

newrelic_rpm
role_requirement

Any help would be great.

Harm

Hi, there’s no certainty that plugins are compatible from release to
release. If the plugin author hasn’t upgraded the plugin for a release,
then you have two choices:

a) wait for the author to update the plugin
b) fix it yourself

From the list that appears above, do you know for certain which plugin
is
causing the problem?

-Conrad

I don’t think the problem is in the plugins. The only one involved in
routing is the new_relic plugin and removing that one is not helping.
I was just providing this information as a possible inroad.
So far I tried the following:

  • My environments.rb file is basically the same as the one in a new
    project.
  • My routes.rb file is being read properly.
  • ‘rake routes’ returns the usual set of routes.
  • Running the server with webrick iso mongrel does not help.

Any other hints?

Harm

On Tue, Mar 17, 2009 at 2:04 AM, Harm [email protected] wrote:

does no longer seem to work for me. I have no idea how this can happen
mimetype-fu
Harm

-Conrad

Hi, did you update your Rails configurations by executing the following:

rake rails:update

-Conrad

I also found, that :_method => :get in link_to_remote doesn’t work
anymore. That is, rails 2.3.2 doesn’t treat it as GET request, but as
POST. so REST route doesn’t work

On Mar 17, 9:08 am, “ruby.freeman” [email protected] wrote:

I also found, that :_method => :get in link_to_remote doesn’t work
anymore. That is, rails 2.3.2 doesn’t treat it as GET request, but as
POST. so REST route doesn’t work

Isn’t _method only there for those methods that browsers won’t use (eg
DELETE). You should be able to make link_to_remote do an actual get
rather than a fake one.

Fred

My initial hunch was correct, thank you Conrad for you pointy question
on which plugin might be the culprit. The plugin ‘smurf’ inserted some
evil map.connects. Totally fixed it now!

Isn’t _method only there for those methods that browsers won’t use (eg
DELETE). You should be able to make link_to_remote do an actual get
rather than a fake one.

the question is - why rails 2.2.2 generates right JS cod for Ajax GET
request, but 2.3.2 isn’t. It doesn’t matter wich exactly method I
write. 2.2.2. generate correct JS code like

new Ajax.Request(’/items’, {asynchronous:true, evalScripts:true,
method:‘get’, …

whereas 2.3.2 does this one

new Ajax.Request(’/items/36497?_method=get…

see the difference?

found. now I have to write ‘_method’ instead of :_method
thanks to all

no, sorry. it still doesn’t work

I did. :S
Even GET requests go wrong. In the routes.rb:
map.resources :forums, :has_many => [:topics]
And doing a GET on (the existing) forums/1/topics gets routed to:
Processing ForumsController#1 (for 127.0.0.1 at 2009-03-17 10:10:29)
[GET]
Parameters: {“id”=>“topics”}

This is very strange.

I am seeing this as well. Only causes problems with xml and xhr
requests. Passing the _method=put on a http request works as expected.
See this ticket for how you can verify the problem. I haven’t come up
with a solution yet.

http://rails.lighthouseapp.com/projects/8994/tickets/2289-_methodput-ignored-for-xhr-and-xml-requests

the solutions is that now we have to set :method => :get in options,
but not in :url hash. then it works