モデルはpost_consultant
とconsultant
です。 post_consultant
とconsultant
の両方がEmployee
モデルへの参照です。だからあなたが言うことができる:私はそれを書くことが出来るのですかレールアソシエーション:同じモデルの2つの発生
モデル
Class Consultation < ActiveRecord::Base
has_one :employee # for consultant
has_one :employee # for post_consultant
end
移行
create_table "consultations", force: :cascade do |t|
t.boolean "showed_up"
t.boolean "signed_up"
t.integer "client_id"
t.integer "consultant_id"
t.integer "post_consultant_id"
end
?
正しいモデル:
class Consultation < ActiveRecord::Base
belongs_to :consultant, class_name: "Employee", foreign_key: "consultant_id"
belongs_to :post_consultant, class_name: "Employee", foreign_key: "post_consultant_id"
end
post_consultantとコンサルタントはモデルですか? – krishnar
post_consultantとコンサルタントのための外部キー? – krishnar
従業員だけが –