【发布时间】:2016-03-15 21:19:28
【问题描述】:
我正在运行 rake db:seed 命令,它没有给出任何错误。但是,我没有通过控制台Event.find(1) 或服务器localhost:3000/events/ 找到此事件。我知道我肯定在某个地方搞砸了。
协会:
class Event < ApplicationRecord
has_one :lineup
has_many :artists, :through => :lineup
belongs_to :venue
end
种子.rb:
Event.create(name: "The function",
date: DateTime.new(2016,2,3,10,0,0,'+7'),
venue: Venue.create(name: "Speakeasy", address: "Lynwood Ave", zip_code: "30312"),
lineup: Lineup.create(:artist => Artist.create(name: "DJ Sliink", bio: "jersey club king")),
description: "free free free")
【问题讨论】:
标签: ruby-on-rails associations seeding