Forum: Ruby on Rails RESTful routing in 2.3 breaks

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2101d75ccd71c5dfb984991a7ba53b9b?d=identicon&s=25 harm (Guest)
on 2009-03-17 09:27
(Received via mailing list)
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
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (conradwt)
on 2009-03-17 09:47
(Received via mailing list)
On Tue, Mar 17, 2009 at 1:27 AM, harm <harmaarts@gmail.com> 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
2101d75ccd71c5dfb984991a7ba53b9b?d=identicon&s=25 Harm (Guest)
on 2009-03-17 10:05
(Received via mailing list)
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
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (conradwt)
on 2009-03-17 10:07
(Received via mailing list)
On Tue, Mar 17, 2009 at 2:04 AM, Harm <harmaarts@gmail.com> 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
04f8f5ce6526ab1d1eb40fe2856c5fcb?d=identicon&s=25 ruby.freeman (Guest)
on 2009-03-17 10:16
(Received via mailing list)
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
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-03-17 10:19
(Received via mailing list)
On Mar 17, 9:08 am, "ruby.freeman" <ruby.free...@gmail.com> 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
2101d75ccd71c5dfb984991a7ba53b9b?d=identicon&s=25 Harm (Guest)
on 2009-03-17 10:19
(Received via mailing list)
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.
2101d75ccd71c5dfb984991a7ba53b9b?d=identicon&s=25 Harm (Guest)
on 2009-03-17 10:41
(Received via mailing list)
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!
04f8f5ce6526ab1d1eb40fe2856c5fcb?d=identicon&s=25 ruby.freeman (Guest)
on 2009-03-17 11:43
(Received via mailing list)
> 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?
04f8f5ce6526ab1d1eb40fe2856c5fcb?d=identicon&s=25 ruby.freeman (Guest)
on 2009-03-17 11:54
(Received via mailing list)
found. now I have to write '_method' instead of :_method
thanks to all
04f8f5ce6526ab1d1eb40fe2856c5fcb?d=identicon&s=25 ruby.freeman (Guest)
on 2009-03-17 12:03
(Received via mailing list)
no, sorry. it still doesn't work
Ec2752c62a8d638f92bfba11cc0c0cf3?d=identicon&s=25 Greg DeVore (Guest)
on 2009-03-18 19:45
(Received via mailing list)
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/ticke...
04f8f5ce6526ab1d1eb40fe2856c5fcb?d=identicon&s=25 ruby.freeman (Guest)
on 2009-03-22 11:47
(Received via mailing list)
the solutions is that now we have to set :method => :get in options,
but not in :url hash. then it works
This topic is locked and can not be replied to.