railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.89k stars 2.26k forks source link

CarrierWave native multiple uploaders issue #2555

Closed bzvyagintsev closed 6 years ago

bzvyagintsev commented 8 years ago

CarrierWave now have experimental feature in master branch - Multiple uploader (based on Postgresql arrays):

class Product < ActiveRecord::Base
   mount_uploaders :images, ProductAdditionalImagesUploader
end

But it dont work with rails_admin. Multiple uploader field doesnt appear in new/edit model pages, and if I do something like that:

 config.model 'Product' do
    list do
      field :images, :carrierwave
    end
  end

Im getting following error

      def resource_url(thumb = false)
            return nil unless (uploader = bindings[:object].send(name)).present?
            thumb.present? ? uploader.send(thumb).url : uploader.url
      end

So, I discovered, that this error appear, because rails_admin cant work with Postgresql arrays, and rails_admin havent multiple uploading feature .

Is there any solutions?

joshua5201 commented 8 years ago

Same problem here.

dedman commented 8 years ago

Just came across this too, anyone come up with a fix?

knopfler81 commented 8 years ago

anything new about this?

DaichiSaito commented 6 years ago

same problem...

krishiaellis commented 6 years ago

same problem

DaichiSaito commented 6 years ago

I dealt with this issue somehow or other... I referred the url below. https://github.com/sferik/rails_admin/wiki/Fields

First I fixed initializers/rails_admin.rb

config.model 'User' do
    list do
      configure :images do # In this case, images is multiple field
        hide
      end
    end

    show do
      configure :images do
        hide
      end
    end

    edit do
      field :name
      field :address
      :
      : (You should write not multiple fields you want to edit)
      :  

      # the multiple field
      field :images do
        partial "my_awesome_partial"
      end
    end
  end

Next, I create new file, app/views/rails_admin/main/_my_awesome_partial.html.erb

<%= form.file_field :images, multiple: true %>
<% @object.myImages.each_with_index do |user, index| %>
  <%= image_tag user %>
  <a class="btn btn-info btn-remove-image" data-confirm="Are you sure you want to delete this image?" rel="nofollow" data-method="delete" href="/user/<%= @object.id %>/images/<%= index %>">Delete</a>

  # The below made an error. I don't know the reason. 
  <%#= link_to "Delete", user_image_path(@object, index), :method => :delete, data: { confirm: "Are you sure you want to delete this image?" } %>
<% end %>
airled commented 6 years ago

Same issue. I use @DaichiSaito 's partial solution but it will be very nice to have some declarative one. Something like

 config.model 'User' do
    edit do
      field images: []
    end
    ...