1

I need to save images in this directory

public/images/clients/1/events/2/banner

and I need to save in my database the url of the image

for example:

public/images/clients/1/events/2/banner/example.png

I have this code:

  if Dir.exist?(params[:dir_images_banner])
    params[:images_banner].each do |image|
      File.open(Rails.root.join(params[:dir_images_banner], image.original_filename), 'wb') do |file|
        file.write(image.read)
      end
    end
  end

but I wanted to do it with the gem paperclip

How could I do this with the gem paperclip?, I need to save the images in a directory and the url of that directory in my database

  • Use activestorage, shrine, carrierwave, ... This is basically what they do: store the location of the image.. don't forget that if you Deploy your application through Heroku you cannot write on the app slug, your images need to be stored in the cloud (AWS S3...) – Maxence Apr 23 '19 at 23:15

0 Answers0