I'm trying to upload fake image data using faker gem, but I am seeing this error:
Paperclip::AdapterRegistry::NoHandlerError: No handler found for "https://robohash.org/app/assets/image.jpg.png?size=300x300&set=set1"
in db/seed.rb
5.times do
Image.create([{
filename:Faker::Food.dish,
title:Faker::Food.dish,
item_image:Faker::Avatar.image('app/assets/image.jpg')
}])
end
in db/image.rb
class CreateImages < ActiveRecord::Migration[5.2]
def change
create_table :images do |t|
t.string :title
t.string :filename
t.timestamps
end
end
end
in db/add_attachment_item_image_to_images.rb (paperclip gem migration file)
class AddAttachmentItemImageToImages < ActiveRecord::Migration[5.2]
def self.up
change_table :images do |t|
t.attachment :item_image
end
end
def self.down
remove_attachment :images, :item_image
end
end
Try with,
Faker::Avatar.image('image.jpg')
Your image must be in app/assets/images
or try following,
File.open(File.join(Rails.root, "app/assets/images/image.jpg"))