has_one
has_many
のリレーションで以下のエラーのため、新規作成、更新ができません。
affiliation
モデルを2回見ているからでしょうか?
エラー内容
Cannot have a has_many :through association 'Attacklist#affiliation' which goes through 'Attacklist#hq_contract_base' before the through association is defined.
現状のリレーション
ruby
1# attacklist.rb 2has_one :base_attacklist, dependent: :destroy 3has_one :affiliation, through: :base_attacklist 4accepts_nested_attributes_for :base_attacklist 5 6has_one :attacklist_hq_contract, dependent: :destroy 7has_one :affiliation, through: :attacklist_hq_contract 8accepts_nested_attributes_for :attacklist_hq_contract
ruby
1# attacklist_hq_contract.rb 2belongs_to :attacklist 3belongs_to :affiliation
ruby
1# base_attacklist.rb 2belongs_to :attacklist 3belongs_to :affiliation
ruby
1# affiliation.rb 2has_many :base_attacklists, dependent: :destroy 3has_many :attacklists, through: :base_attacklists 4has_many :attacklist_hq_contract_bases, dependent: :destroy 5has_many :attacklists, through: :attacklist_hq_contract_bases
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。