A true newbie here ^^
I'm trying to use the Faker gem to seed x number of Items/Cards in an online store project. All good except for one thing. I don't know how to seed a different image per Item/Card created.
10.times do Item.create!(title: Faker::Book.title, description: Faker::Lorem.sentence(5), price: prices.sample, image_url: Faker::LoremFlickr.image) end Is there a way to seed a different image for each card?
Thank you :)
1 Answer
According to the faker docs you can prefix your method call with unique like this:
10.times do Item.create!(title: Faker::Book.title, description: Faker::Lorem.sentence(5), price: prices.sample, image_url: Faker::LoremFlickr.unique.image) end 2