2
我是Rails的新手。我有两个模型,人和日。Rails 2.3.8关联问题has_many belongs_to
class Person < ActiveRecord::Base
has_many :days
end
class Day < ActiveRecord::Base
belongs_to :person
has_many :runs
end
当我尝试访问@ person.days我得到一个SQL错误:
$ script/consoleLoading development environment (Rails 2.3.8)
ree-1.8.7-2010.02 > @person = Person.first
=> #<Person id: 1, first_name: "John", last_name: "Smith", created_at: "2010-08-29 14:05:50", updated_at: "2010-08-29 14:05:50"> ree-1.8.7-2010.02
> @person.days
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: days.person_id: SELECT * FROM "days" WHERE ("days".person_id = 1)
我安装运行任何迁移前两者之间的关联,所以我不明白为什么这有没有正确设置。
有什么建议吗?