这是我的课程模型
class Course < ActiveRecord::Base
attr_accessible :longdescription, :shortdescription, :title, :published_at
has_many :lessons, :foreign_key => 'course_id'
end
这是我的课程模型
class Lesson < ActiveRecord::Base
belongs_to :course, :class_name => 'Course'
attr_accessor :course_id
attr_accessible :description, :title, :course_id
end
我创建了属于课程的课程。课程创建成功
Lesson.create(:title => "testing", :description => "causing problems", :course_id => 1)
但是当我获取课程记录时,我得到了 course_id=nil。任何帮助???
<Lesson id: 8, title: "testing", description: "causing problems", course_id: nil, created_at: "2013-03-15 12:56:36", updated_at: "2013-03-15 12:56:36">