Я недавно обновил это приложение с рельсов 2.2.2 до 2.3.11. Все работало нормально до обновления. После обновления я получаю следующую ошибку:
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.
В подарочной модели:
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
Модель черты:
class Trait < Field
has_and_belongs_to_many :traits
end
Почему обновление с 2.2.2 до 2.3.11 приводит к этой ошибке?