I am new to rails. Based on the experience with django, I was too lazy to write the admin panel with my hands and I began to use an active admin. I ran into the problem of loading images. 1) I do not know how to specify the download path 2) I do not know how to download the file. Thank you in advance! here is my code:

ActiveAdmin.register Imgpost do permit_params :title, :image index do column :title column :image actions end filter :title form(:html => { :multipart => true }) do |f| f.inputs "Create new image post", :multipart => true do f.input :title f.input :image, :as => :file end f.actions end end` 

    2 answers 2

    To begin with, the description is not words about gems for downloading files. If there really aren't any, you can use this gem 'carrierwave' . Documentation on it can be found here.

    After installing it, run the command rails generate uploader MyUploader

     class MyUploader < CarrierWave::Uploader::Base #тут указываем директорию в которую хотим загружать файлы def store_dir 'public/my/upload/directory' end end 

    If you need to upload a picture from the admin - heme himself should make friends with this form, if from the "client part" - then in the form that is responsible for the building object you need to add a field for downloading files

      = form_for @object, :html => {:multipart => true} do |f| .col-xs-12.col-sm-4 = f.file_field :image, html: {class: 'img-responsive'} 

      There is a Paperclip gem for working with files. Here is a link to his page.

      Then in the migration of approximately sl .: t.attachment :jpg_products , and in the model:

       has_attached_file :jpg_products, :default_url => '/assets/no-photo.png', :styles => { :original => "800x600!", :small => "268x198!" }, :default_style => :small, :convert_options => { :all => "-quality 85 -strip" } 

      in the controller you work with it as with a regular field.

      Once again: here hem itself and detailed instructions for setting up, installation ..