【发布时间】:2018-04-04 18:35:39
【问题描述】:
我正在尝试为我的 Photoshoot 模型上传种子数据,该模型由多个 for url 组成,如下所示:
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
}
但我在种子中收到以下错误消息:
NoMethodError:
的未定义方法 `photos_urls='我的模型如下:
class Photoshoot < ApplicationRecord
has_attachment :photos, maximum: 20
belongs_to :photograph
belongs_to :user
end
【问题讨论】:
标签: ruby-on-rails ruby cloudinary