2017-10-24 1 views
0

Ich versuche Seed-Daten für mein Fotoshooting Modell hochladen zu laden, die für URLs wie so aus mehreren besteht:kann nicht Seed-Daten mit Attachinary gem „nicht definierte Methode` photos_urls =‘für das Objekt“

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 
} 

Aber ich erhalte die folgende Fehlermeldung in meinem Samen:

NoMethodError: nicht definierte Methode `photos_urls‚= für

Mein Modell ist folgende:

class Photoshoot < ApplicationRecord 
    has_attachment :photos, maximum: 20 
    belongs_to :photograph 
    belongs_to :user 
end 

Antwort

0

Anlage hinzufügen Pfad

has_attached_file :photo, 
:styles => { 
:thumb=> "", 
:small => ""}, 
:path => "uploads/:class/:attachment/:id_partition/:style/:basename.:extension", 
:url => "uploads/:class/:attachment/:id/:style/:basename.:extension" 
Verwandte Themen