No links to individual records in records in an index page for STI parent
Reported by Betelgeuse | December 5th, 2009 @ 06:15 PM | in Beyond Hobo 1.0
I am experimenting with STI. The child models have no logic specific to views so I am using the parent for all the routes etc. The index page seems otherwise fine but there are no links to individual records. This seems to be a problem in Hobo::ModelRouter.
(rdb:1) p Hobo::ModelRouter.linkable?(klass, action, options)
false
I think link will appear if we make the code try to find a working route for the parent class if the child class doesn't work. This is on 0.9.0 as 0.9.102 has regressions breaking my tests but looking at git log for model_router.rb there doesn't seem to anything different related to this bug.
Comments and changes to this ticket
-
Betelgeuse December 5th, 2009 @ 11:49 PM
For now I worked around this by overriding self.to_url_path in the parent and by calling Hobo::ModelRouter.linkable! for the child classes and :show action and what I need seems to be working fine.
-
Matt Jones December 6th, 2009 @ 07:23 PM
- Assigned user set to Matt Jones
- Tag set to defect, routing, sti
- Milestone set to Hobo 1.0 - Final
Just to clarify - do you have controllers for the subclasses, or is that also being handled by the parent's controller? Could be relevant to tracking this down...
BTW, if you can ticket the test-breaking regressions it would be much appreciated. :)
-
Betelgeuse December 6th, 2009 @ 07:33 PM
I recommend following the RSS feed for this lighthouse project. Had you followed that, you would have seen that I have already filed #567.
I don't have controllers for the subclasses, it's handled by the controller of the parent. -
Matt Jones January 12th, 2010 @ 07:04 PM
- State changed from new to open
- Milestone changed from Hobo 1.0 - Final to Beyond Hobo 1.0
Some notes:
-
the ModelRouter part is pretty straightforward to fix; all that's needed is a chase up the inheritance chain to find if there's a routable superclass.
-
However, the actual URL generation is messier, as to_url_path doesn't do any checking r/e visibility. We'll need to do something similar to your manual workaround (probably in add_routes) to handle this case.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป