This project is archived and is in readonly mode.
polymorphic routes should handle collections through Model Class
-
Pratik
- Tag changed from actionpack, polymorphic, routes to 2.1, actionpack, polymorphic, routes
Could you please upload a patch using git-format-patch ?
Thanks.
-
Pratik
http://rails.lighthouseapp.com/p... should help.
-
Yehuda Katz (wycats)
@mamooth is there any chance you could provide tests that represent the desired output, not just the fact that articles_url will be called. This will help us ensure that your desired behavior does not break through any upcoming refactoring.
-
Niklas Holmgren
- Tag changed from 2.1, actionpack, polymorphic, routes to 2.1, actionpack, patch, polymorphic, routes
Created a patch complete with tests. Think I got all possible cases nailed.
-
CancelProfileIsBroken
- State changed from incomplete to open
-
José Valim
- Tag changed from 2.1, actionpack, patch, polymorphic, routes to 2.1, actionpack, bugmash, patch, polymorphic, routes
-
Dan Pickett
+1 verified - I've attached an updated patch for 2-3 stable
We should probably document this a little more.
Also it could lead to some misleading behavior as it relates to STI models. Overall, though it could be very handy. Good idea
-
Dan Pickett
trying to upload the patch for some reason it didn't take the first time
-
Dan Pickett
attached a patch
-
Dan Pickett
attached a patch against master per Lifo's request
-
Yehuda Katz (wycats)
"Also it could lead to some misleading behavior as it relates to STI models." Do you know of any existing behavior this could break? I'm a bit wary of handy features that break existing assumptions. I'm posting to the list for more feedback.
-
José Valim
@Yehuda,
He might be referring that the model SuperProject should have "/projects" as url, instead of "/super_projects" (which would be the default). Anyway, this problem already appears today and I already saw a ticket around here to solve the issue (although I don't think the solution should rely on polymorphic_url).
Thinking out loud here, maybe we should add to ActiveModel::Naming something like route?
-
Repository
- State changed from open to resolved
(from [c284412b149e03f46144ef566bcd6a16750961b1]) Polymorphic routes generates collection URL from model class [#1089 polymorphic routes should handle collections through Model Class state:resolved]
Signed-off-by: Dan Pickett dpickett@enlightsolutions.com
Signed-off-by: Pratik Naik pratiknaik@gmail.com
http://github.com/rails/rails/commit/c284412b149e03f46144ef566bcd6a... -
Yehuda Katz (wycats)
- State changed from resolved to open
José: It's hard to add to naming, because the whole issue is that you can't calculate it (you have to try the subclass first and then the superclass). Maybe you're saying to cache it on naming for a given app? Again, this could get complicated in the case of multiple apps in the same process (not something you can do today, but worth keeping in mind). I think it makes more sense to cache on the router instance, which will always have one per application.
-
José Valim
@Yehuda, agreed. I also proposed a router based solution on #1231 polymorphic_url gives incorrect url for :has_one nested resource, which is also about polymorphic_url.
-
Pratik
- State changed from open to resolved
Feel free to reopen AFTER there are any known issues. STI problem is a separate issue.
-
CancelProfileIsBroken
- Tag changed from 2.1, actionpack, bugmash, patch, polymorphic, routes to 2.1, actionpack, patch, polymorphic, routes
- Milestone cleared.
