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