Estou criando um model teacher que possui um contact:
ActiveAdmin.register Teacher do
permit_params :name, :contact_id
form do |f|
f.semantic_errors *f.object.errors.keys
f.inputs "Details" do
f.input :name
f.input :contact_id, :as => :select, :collection => Contact.all.collect {|contact| [contact.email] }
end
f.actions
end
end
aqui está o model contact
ActiveAdmin.register Contact do
permit_params :phone, :email
end
Aqui está o schema:
ActiveRecord::Schema.define(version: 2019_11_12_175353) do
create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace"
t.text "body"
t.string "resource_type"
t.integer "resource_id"
t.string "author_type"
t.integer "author_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id"
t.index ["namespace"], name: "index_active_admin_comments_on_namespace"
t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id"
end
create_table "admin_users", force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["email"], name: "index_admin_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
end
create_table "contacts", force: :cascade do |t|
t.string "phone"
t.string "email"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "groups", force: :cascade do |t|
t.string "description"
t.integer "teacher_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["teacher_id"], name: "index_groups_on_teacher_id"
end
create_table "students", force: :cascade do |t|
t.string "name"
t.integer "teacher_id"
t.integer "contact_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["contact_id"], name: "index_students_on_contact_id"
t.index ["teacher_id"], name: "index_students_on_teacher_id"
end
create_table "subjects", force: :cascade do |t|
t.string "description"
t.integer "teacher_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["teacher_id"], name: "index_subjects_on_teacher_id"
end
create_table "teachers", force: :cascade do |t|
t.string "name"
t.integer "contact_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["contact_id"], name: "index_teachers_on_contact_id"
end
end
Estou tendo um erro contact must exist mesmo com os dados do contato aparecendo em teacher.
Ruby 2.4, active admin e wicked_pdf, e sqlite, se isso for relevante.
Já tentei https://github.com/rails/rails/issues/24518 mas não funciona, retorna outro erro.