0

I m trying to generate some test data on the test environment, and have some random PDF urls that we can use for testing. My AR class looks like this :

class PDF::Template < ActiveRecord::Base
  mount_uploader :document, PdfUploader
end

Using ruby code or code that I can run via rake task or via rails console? How can I upload something from random pdf url?

Remember_me
  • 223
  • 4
  • 18
  • Possible duplicate of [Uploading a remote file url from Rails Console with Carrierwave](https://stackoverflow.com/questions/16918588/uploading-a-remote-file-url-from-rails-console-with-carrierwave) – mdesantis May 30 '18 at 15:46

1 Answers1

1

From Carrierwave wiki:

If you're looking to quickly generate some seed data for your application and don't want to upload images already stored in your application you can easily upload remote images by using remote_[your_image_attribute_name]_url

    Galaxy.destroy_all
    Galaxy.create!(name: 'Andromeda', remote_photo_url: 'http://apod.nasa.gov/apod/image/1407/m31_bers_960.jpg', address: 'next to the Milky Way')
mdesantis
  • 8,257
  • 4
  • 31
  • 63