Ruby on rails rails已经通过了很多次。没办法让它发挥作用
我试图通过联想创造一个有很多的人,但我一定是弄错了 我相信我得到了正确的关联代码,但当我尝试创建连接记录时,这就是我得到的 1.9.3p194:001>d=Day.find1 Day Load 3.9ms选择天数。*从days.id=?限制1[[id,1]]=> 1.9.3p194:002>d.students.创建!:id=>1 0.1ms开始事务SQL 2.0ms插入学生在, 名称,在值?,?,?处更新?[[于4月18日星期四创建] 2013年12:49:25 UTC+00:00],[姓名,无],[更新日期:4月18日,星期四 2013年12:49:25 UTC+00:00]]0.8毫秒回滚事务 ActiveRecord::UnknownAttributeError:未知属性:天\u id 模型 day_students表中的属性应为: 第二天 学生证Ruby on rails rails已经通过了很多次。没办法让它发挥作用,ruby-on-rails,has-many-through,Ruby On Rails,Has Many Through,我试图通过联想创造一个有很多的人,但我一定是弄错了 我相信我得到了正确的关联代码,但当我尝试创建连接记录时,这就是我得到的 1.9.3p194:001>d=Day.find1 Day Load 3.9ms选择天数。*从days.id=?限制1[[id,1]]=> 1.9.3p194:002>d.students.创建!:id=>1 0.1ms开始事务SQL 2.0ms插入学生在, 名称,在值?,?,?处更新?[[于4月18日星期四创建] 2013年12:49:25 UTC+00:00],[姓名,
# == Schema Information
#
# Table name: students
#
# id :integer not null, primary key
# name :string(255)
# created_at :datetime not null
# updated_at :datetime not null
#
class Student < ActiveRecord::Base
attr_accessible :name
has_many :days, :through => :days_students
has_many :days_students, :dependent => :destroy, :class_name => "DayStudent"
end
# == Schema Information
#
# Table name: days
#
# id :integer not null, primary key
# created_at :datetime not null
# updated_at :datetime not null
#
class Day < ActiveRecord::Base
#attr_accessible
has_many :students, :through => :days_students
has_many :days_students, :dependent => :destroy, :class_name => "DayStudent"
end
# == Schema Information
#
# Table name: day_students
#
# id :integer not null, primary key
# students_id :integer
# days_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
class DayStudent < ActiveRecord::Base
attr_accessible :student_id, :day_id
belongs_to :day
belongs_to :student
end