2013-12-17 106 views
2

我要让类似的照片廊我的每个产品在rails_adminrails_admin多图像上传?

但对于不同的产品我想添加的照片不同的量。

因此,我有我的Product模型与has_one :gallery协会和我的Gallery模型与belongs_to :product协会。

我怎么能在rails_admin model多个字段,当我不知道我会怎么诸多领域,需要什么呢?

或者我怎样才能通过回形针在rails_admin上传多个文件?

+2

尼斯评论,你帮了我很多。谢啦。 – Phil

+0

没问题。我是一个很好的自我定式主义鼓励者。 –

回答

1

你可以使用accepts_nested_attributes_for

class Photo < ApplicationRecord 
    belongs_to :gallery, inverse_of: photos 
    has_attached_file :image 
end 

class Gallery 
    has_many :photos 
    accepts_nested_attributes_for :photos 
end 

,这将让你这样的:

enter image description here

通知,只要你想,你如何能够尽可能多的照片。

+0

感谢您的回答。 4年后不幸的是这个问题失去了它的意义:) – Phil

+0

哈哈是啊注意到,瞬间回答后。 我以为我可以在未来的谷歌有用。 –