1
我試圖讓自己上傳5個圖像爲每個模型使用活動管理,但我似乎無法弄清楚如何做到這一點。這裏是我的活動管理員代碼到目前爲止:使用activeadmin一次用回形針上傳多個圖像
ActiveAdmin.register Piece do
form :html => { :enctype => "multipart/form-data" } do |f|
f.inputs "Details" do
f.input :name
f.input :description
f.input :cost
f.input :category
f.input :photo, :as => :file, :hint => f.template.image_tag(f.object.photo.url(:medium))
end
f.buttons
end
index do
column :id
column :name
column :cost
column :category
column :inventory_count
column :available_count
column :materials
column :created_at
default_actions
end
end
我該如何允許一次5而不是1?
在你的作品模型定義,不是have_many:照片,或者是附照片一塊?你需要先獲得Piece的照片。 –
它has_attached_file:照片。如果我切換到has_many,它會怎樣?那工作怎麼樣? –