मैंने हाल ही में इस एप्लिकेशन को रेल 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 उपज के उन्नयन करता है यह गलती?
"स्वयं नहीं बना सकता"। निश्चित रूप से लगता है कि किसी की तरह अस्तित्ववाद बहुत कम गंभीरता से ले रहा है। – Layke
क्या आप अपने 'ट्राइट' मॉडल के कोड को शामिल करने के लिए अपना प्रश्न संपादित कर सकते हैं। –
@ जॉन टोप्ली ओप्स ... पोस्ट मॉडल में पोस्ट किया गया। – Jay