I've been struggling for a week now, I'm trying to create a form inside active_admin where a user can select several pictures, add a description and a title, then submitting his form to create something that would look like a gallery
So far, I have two models created with the commands:
rails g model Gallery title:string description:text
rails g model Image url:text #just in case the user has LOTS of images to upload
Here are how look my models now:
gallery.rb
class Gallery < ApplicationRecord
has_many :images
accepts_nested_attributes_for :images, allow_destroy: true
end
image.rb
class Image < ApplicationRecord
belongs_to :gallery
mount_uploader :image, ImageUploader #Using Carrier Wave
end
admin/gallery.rb
permit_params :title, :description, :images
form html: { multipart: true } do |f|
f.inputs do
f.input :title
f.input :description
f.input :images, as: :file, input_html: { multiple: true }
end
f.actions
end
My problem is that even though my 'image' form shows up, I can't manage to save the images through the other model, nothing gets uploaded inside my 'public/upload' directory, and nothing gets written inside my database.
I can't find anything interesting internet that could solve this problem
Feel free to ask for another file
Any help welcome