Polymorphic Rails reference for nested index action

I have been trying to find this link for several hours. I have a polymorphic association in which there are both collections and an assortment.

Collection Model

has_many :designs, :as => :targetable

Assortment Model

has_many :designs, :as => :targetable

Design model

belongs_to :targetable, :polymorphic => true


To associate a show action with a design, the correct polymorphic path is:

link_to polymorphic_path([@targetable, @design])

But I can’t understand how to associate a design page with an index to show all the projects associated with it corresponding to the target.

Does anyone know a suitable link to get there?

+3
source share
1 answer

Finally, I was able to find the answer.

polymorphic_path([@targetable, Design])

, , .

targetable/:targetable_id/designs

, - .

+7

Source: https://habr.com/ru/post/1660362/


All Articles