Niedawno zaktualizowałem tę aplikację z szyn 2.2.2 do 2.3.11. Wszystko przebiegało dobrze przed aktualizacją. Po uaktualnieniu otrzymuję następujący błąd:Nie można utworzyć błędu samooceny
ActiveRecord::HasAndBelongsToManyAssociationForeignKeyNeeded in InstrumentsController#arrow
Cannot create self referential has_and_belongs_to_many association on 'Trait#traits'. :association_foreign_key cannot be the same as the :foreign_key.
W modelu Gift: modelu
class Gift < ActiveRecord::Base
has_many :delegate_gifts
has_many :answers
belongs_to :feel_motive, :class_name => "Trait", :foreign_key => "feel_motive_id"
belongs_to :see_motive, :class_name => "Trait", :foreign_key => "see_motive_id"
belongs_to :incline_motive, :class_name => "Trait", :foreign_key => "incline_motive_id"
has_and_belongs_to_many :users
has_and_belongs_to_many :best_contributions
def traits
traits = []
traits << feel_motive unless feel_motive.nil?
traits << see_motive unless see_motive.nil?
traits << incline_motive unless incline_motive.nil?
return traits
end
end
cecha:
class Trait < Field
has_and_belongs_to_many :traits
end
Dlaczego aktualizacji z 2.2.2 do 2.3.11 produktów ten błąd?
"Nie można utworzyć siebie". Zdaje się, że ktoś zbyt poważnie traktuje egzystencjalizm. – Layke
Czy możesz edytować swoje pytanie, aby dołączyć kod dla swojego modelu 'Trait'. –
@JohnTopley oops ... model cech dodany do postu. – Jay