我有两个对象 - 材料 - 课
每种材料都可以拥有并属于课程;每节课都可以拥有和属于材料。
当我尝试创建时在 material_controller 中
@material = Material.new(params[:material])
class Material < ActiveRecord::Base
has_and_belongs_to_many :lessons
attr_accessible :content_type, :user_id, :lesson_ids
这是参数
"material"=>{"content_type"=>"2",
"detail_content"=>"",
"user_id"=>"5",
"lesson_ids"=>"[]"},
create_table "lessons", :force => true do |t|
t.string "title"
t.string "description"
t.integer "course_id"
t.integer "sequence"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "lessons_materials", :force => true do |t|
t.integer "lesson_id"
t.integer "material_id"
end
create_table "materials", :force => true do |t|
t.integer "content_type"
t.text "detail_content"
t.text "embedded_content"
t.string "stored_file_name"
t.string "stored_content_type"
t.integer "stored_file_size"
t.datetime "stored_updated_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.integer "user_id"
end