0
爲什麼沒有保存關聯的記錄ID?activeadmin一對一關聯不保存ID
Diagram of database
Console error message
教師遷移
class CreateTeachers < ActiveRecord::Migration
def change
create_table :teachers do |t|
t.string :name
t.belongs_to :classroom
t.timestamps
end
end
end
教室遷移
class CreateClassrooms < ActiveRecord::Migration
def change
create_table :classrooms do |t|
t.string :name
t.timestamps
end
end
end
模型/ teacher.rb
class Teacher < ActiveRecord::Base
belongs_to :classroom
end
模型/ classroom.rb
class Classroom < ActiveRecord::Base
has_one :teacher
end
應用程序/管理/ teacher.rb
ActiveAdmin.register Teacher do
permit_params{
:id
:classroom_id
:name
}
end
請問您能否顯示您的視圖和控制器? – 2014-12-01 16:45:23
由於activeadmin,沒有控制器或視圖。我正在使用生成的默認視圖。到目前爲止,app/admin/teacher.rb文件中只有許可參數。 – sasdev 2014-12-01 17:07:02