Recientemente he actualizado esta aplicación desde los carriles 2.2.2 a 2.3.11. Todo estaba funcionando bien antes de la actualización. Después de la actualización que estoy recibiendo el siguiente error:No se puede crear el error autorreferencial
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.
En el modelo de regalo: modelo
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
rasgo:
class Trait < Field
has_and_belongs_to_many :traits
end
¿Por qué actualizar de 2.2.2 a 2.3.11 productos ¿este error?
"No se puede crear uno mismo". Definitivamente parece que alguien está tomando demasiado en serio el existencialismo. – Layke
Puedes editar tu pregunta para incluir el código de tu modelo 'Trait' por favor. –
@JohnTopley oops ... modelo de rasgo agregado a la publicación. – Jay