I have been trying to find this one link for hours now. I have a polymorphic association where both collections & assortments have designs.
Collection model
has_many :designs, :as => :targetable
Assortment model
has_many :designs, :as => :targetable
Design model
belongs_to :targetable, :polymorphic => true
In order to link to the design's 'show' action, the proper polymorphic path would be:
link_to polymorphic_path([@targetable, @design])
But I can't figure out how to link to the design's 'index' page to show all the designs associated with it's respective targetable object.
Does anyone know the appropriate link to get there??
I was finally able to find the answer.
polymorphic_path([@targetable, Design])
Instead of using a variable as the second object in the polymorphic path, you are supposed to use the model name. This path links to
targetable/:targetable_id/designs
Maybe this will help someone for future use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With