Coding child
Coding child

Reputation: 155

how to add an upload button to active admin

I am trying to add a button which will call a popup windows to upload a file on a server. I am looking for paperclip alternative without need to use image preprocessor.

User flow is going to be next: - Log in into active admin - Click create new photo - Pick photo using file picker (a place where I am stuck) - Upload selected picture onto cloudinary or something similar to it.

I really could use paperclip but I am afraid it will require to many other dependencies on production server. What would you advice, my friend?

Upvotes: 0

Views: 1527

Answers (1)

Alex
Alex

Reputation: 2518

The simplest solution I can think of looks something like this:

ActiveAdmin.register User do
  form :html => { :multipart => true } do |f|
    f.inputs "Upload" do
      f.input :image, :type => :file
    end
    f.actions
  end
end

Maybe you missed the multipart attribute? Nevertheless, I'd suggest you to take a look at carriverwave (https://github.com/carrierwaveuploader/carrierwave).

If this is not helping you at all, please post some code examples. That will make it much easier for others to provide you some useful feedback.

Upvotes: 2

Related Questions