[英]One Carrierwave Uploader shared between Two Models in ActiveAdmin
I have one CarrierWave Uploader called documents . 我有一个CarrierWave Uploader,称为文档 。
Three Models: 三种型号:
I currently have ActiveAdmin setup: app/admin/document.rb 我目前有ActiveAdmin设置: app / admin / document.rb
belongs_to :university
That works well, however, when I try adding another belongs_to :webinar_content association, I get the following error: 效果很好,但是,当我尝试添加另一个belongs_to:webinar_content关联时,出现以下错误:
Couldn't find University with 'id'=
Any idea on how to resolve this? 关于如何解决这个问题的任何想法?
Without seeing your schema, its hard to tell. 没有看到您的架构,很难分辨。 Though I suspect you want polymorphic associations. 虽然我怀疑您想要多态关联。
http://guides.rubyonrails.org/association_basics.html#polymorphic-associations#polymorphic-associations http://guides.rubyonrails.org/association_basics.html#polymorphic-associations#polymorphic-associations
Basically you want your document to belongs_to :documentable
having a documentable_id
and a documentable_type
on the Document
model. 基本上,你希望你的文档belongs_to :documentable
有documentable_id
和documentable_type
的Document
模型。
Then on your other models you wish to upload documents to you have has_many :documents
然后在其他模型上,您希望将文档上载到has_many :documents
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.