Closed iHiD closed 12 years ago
The bigger issue is that match_routes seems to always contain all routes that have redirect as part of them, even if they don't in any way match - this means I never get a routing error.
The never getting a routing error should be fixed by c70e548, which was part of the Journey 1.0.4. It's not just redirect routes - all mounted Rack applications are also included.
Also, could someone please advise me where best to post the issue with user/media_files vs User::MediaFiles not working in the same way (IMO, they should both work two-ways or one should not work at all). I'm not sure whether that falls under ActiveDispatch or here.
Controllers should always be written as 'user/media_files' and not 'User::MediaFiles'. All the examples in the Rails documention are in snakecase so I'm not sure where you'd get the idea that using camelcase is appropriate. However I'm sure that a simple regexp to validate the controller name could be added to raise an error where camelcase is used. If you'd feel up to it please create a PR on the Rails project or create an issue and I'll take a look at it.
The never getting a routing error should be fixed by c70e548, which was part of the Journey 1.0.4. It's not just redirect routes - all mounted Rack applications are also included.
Brilliant, thanks. Sorry for the duplicate in that case.
All the examples in the Rails documention are in snakecase so I'm not sure where you'd get the idea that using camelcase is appropriate.
Yeah, it's pretty old code. I honestly have no idea :) It's worked fine up till now, until I used url_for()
in some pagination, which then highlighted the other problem. I'll put a PR up in Rails when I have chance.
Thanks for responding so promptly - I'll close this now.
This issue persists in Journey 1.0.4. It accounts correctly for Rack applications, but the redirect routes are still being matched.
Hi guys,
I've been struggling for a few hours with a wrong route being generated when using
url_for
. I've solved why that's happening, but I believe the the symptom I was getting is a different bug.Minimal App
To create a minimal app that highlights the problem (you can just copy paste this in)
Change the routes.rb to:
And add the following to the end of both
app/views/users/index.html.erb
andapp/views/user/media_files/index.html.erb
/users/
./users?foo=bar
/users/new
./users/1/media_files
/google?controller=user%2Fmedia_files&foo=bar
Where it occurs
As far as I can tell, this occurs on any page that has a URL that cannot itself be reverse engineered. If you change the route from:
resources :media_files, class_name: "User::MediaFiles"
to:resources :media_files, class_name: "user/media_files"
then the error will go away, becauseurl_for
will correctly find the route.The bigger problem
The bigger issue is that match_routes seems to always contain all routes that have
redirect
as part of them, even if they don't in any way match - this means I never get a routing error.Specifically this is my output of the hash after it has been 'scored':
I've just lost most of my day tracking down this (and specifically the change in the
routes.rb
), so I can't look into this any more at the moment, but I hope someone who has more knowledge of the code might be able to see quickly why this happens.Also, could someone please advise me where best to post the issue with
user/media_files
vsUser::MediaFiles
not working in the same way (IMO, they should both work two-ways or one should not work at all). I'm not sure whether that falls under ActiveDispatch or here.Thanks for all your hard work guys - I hope it's a quick one to solve! Jez (iHiD)