ROR + ActiveAdmin + Carrierwave, editing after loading multiple images

I have a ROR application that works with ActiveAdmin and uses CarrierWave to load images. I have a model: A product that allows you to use multiple ProductImages. Everything seems to be going well when it simply adds a new product and selects a few images to upload. But as soon as I want to edit this product, the image does not seem to be uploaded, plus I get the following error:

undefined method `image_changed?' 

My guess is that the bootstrap does not do much and therefore ends up empty when editing.

Here is a snippet of the admin form:

 ActiveAdmin.register Product do form(:html => {:multipart => true}) do |f| f.inputs "Details" do f.input :name f.input :descr, :label => "Description" f.input :brand, :as => :select, :collection => Brand.all, :member_label => :name, :label => "Brand" # tags f.autocomplete_field :tag_list, '/products/autocomplete_tag_name', :"data-delimiter" => ', ' f.input :tag_list, :hint => "Comma delimited tags" end f.has_many :product_images do |pi| pi.inputs "Product Images" do if !pi.object.nil? pi.input :_destroy, :as => :boolean, :label => 'Destroy?' end pi.input :image_name pi.input :image end end f.buttons end end 

change

I know one more thing, images are loaded when creating a message, its editing comes from it.

+4
source share
2 answers

I had the same issue (but with Paperclip) a while ago. The solution (not obvious) was that the image was not updated if the user had not provided his password in the editing form to confirm the update.

So, if you haven’t done this, it might be worth it: ask the user to enter their password when editing the Product and see if the images are updated correctly.

0
source

I recently ran into this problem. Update the form field as shown below. You must set the input field as a file.

 pi.input :image, :as => :file 
0
source

Source: https://habr.com/ru/post/1416531/


All Articles