0

I'm trying to upload seed data for my Photoshoot model which consists of multiple for urls like so:

10.times {
  urls = [
    'http://lorempixel.com/400/400/',
    'http://lorempixel.com/400/400/',
    'http://lorempixel.com/400/400/',
    'http://lorempixel.com/400/400/',
    'http://lorempixel.com/400/400/',
    'http://lorempixel.com/400/400/',
    'http://lorempixel.com/400/400/',
    'http://lorempixel.com/400/400/'
  ]
  time = Faker::Time.between(DateTime.now - 1, DateTime.now + 3)
  photoshoot = Photoshoot.new( user_id: Faker::Number.between(1, 19), photograph_id: Faker::Number.between(1, 19), start_time: time, end_time: time + Faker::Number.between(1, 2).hours, message: Faker::TheFreshPrinceOfBelAir.quote )
  photoshoot.save!
  photoshoot.photo_urls = urls
}

But I'm getting the following error message in my seed:

NoMethodError: undefined method `photos_urls=' for

My model is the following :

class Photoshoot < ApplicationRecord
  has_attachment :photos, maximum: 20
  belongs_to :photograph
  belongs_to :user
end
Hugo Hyz
  • 41
  • 2
  • 10

1 Answers1

0

Add attachment path

has_attached_file :photo,
:styles => {
:thumb=> "",
:small  => ""},
:path => "uploads/:class/:attachment/:id_partition/:style/:basename.:extension",
:url => "uploads/:class/:attachment/:id/:style/:basename.:extension"
Qmr
  • 64
  • 1
  • 7