ruby on rails - active_admin and adding multiple images to gallery -
i'm using active_admin , carrierwave gems. have 2 simple models:
class image < activerecord::base attr_accessible :gallery_id, :file belongs_to :gallery mount_uploader :file, fileuploader end class gallery < activerecord::base attr_accessible :description, :title, :file, :images_attributes has_many :images accepts_nested_attributes_for :images, allow_destroy: true mount_uploader :file, fileuploader end
now active_admin form gallery looks this:
form |f| f.inputs "gallery" f.input :title end f.has_many :images |ff| ff.input :file end f.actions end
now can upload 1 file, click "add new image" , upload one. instead of it, i'd click "add new image", select multiple files , upload them @ once. idea how can implement it?
for gallery form multiple image uploads can try this
admin/galleries.rb
form |f| f.inputs "gallery" f.input :name end f.has_many :images |ff| ff.input :file end end
in model/gallery.rb:
attr_accessible :images_attributes
in model/gallery.rb (add after relations):
accepts_nested_attributes_for :images, :allow_destroy => true
Comments
Post a Comment