0
我有基本的設置多態性網址:軌創建多態模型
class Document < ActiveRecord::Base
belongs_to :documentable, polymorphic: true
end
class Contact < ActiveRecord::Base
has_many :documents, as: :documentable
end
class Case < ActiveRecord::Base
has_many :documents, as: :documentable
end
現在_index.html.erb的我的文檔查看,我要做到以下幾點:
<%= link_to "New Document", polymorphic_path([:new, @documentable, Document.new]) %>
哪裏@documentable將成爲聯繫人或案例的實例。
我期望上面生成一個url像new_contact_document_path,但它只是試圖產生一個url像new_documents_path。
我會做什麼錯?
這也適用於許多嵌套的路線:new_polymorphic_path([@ model1,@ model2,Model3]) – Donato