Rails 4, Carrierwave, Remote file url uploading

If you’re running into the following error when attempting to use Carrierwave to upload a remote file url:

TypeError: no implicit conversion of nil into String

Then you’re probably very frustrated at the moment. I dug into the carrierwave gem to figure the issue out exactly, however I realized there was an easier (and much quicker solution).

If you want to upload a remote file URL using carrierwave, use the following syntax:

@photo = MediaItem.new
@photo.remote_photo_url = "http://www.example.com/url-to-picture-or-other-file"
@photo.save

 

Above, you’ll notice “photo” is emphasized. This value will change according to the name of your uploader. In our case, it is “photo”, however it can be anything.

Leave a Reply

Your email address will not be published. Required fields are marked *