मैं SQLite के साथ एक रेल 4.0 आवेदन पर काम कर रहा है (रेल के लिए डिफ़ॉल्ट विकास पर्यावरण) घटनाओं (हैकथॉन) के लिए जिसमें एक मूल मॉडल, इवेंट है, जिसके लिए कई Press_Blurbs हो सकते हैं।रेल 4: schema.db से पता चलता घटनाओं "तालिका डंप नहीं किया जा सका" "निम्नलिखित NoMethodError # अपरिभाषित विधि की वजह से` [] 'शून्य के लिए: NilClass "
class CreateEvents < ActiveRecord::Migration
def change
create_table :events do |t|
t.string :city
t.string :theme
t.datetime :hackathon_start
t.datetime :hackathon_end
t.datetime :show_start
t.datetime :show_end
t.text :about
t.string :hack_rsvp_url
t.string :show_rsvp_url
t.timestamps
end
end
end
class CreatePressBlurbs < ActiveRecord::Migration
def change
create_table :press_blurbs do |t|
t.string :headline
t.string :source_name
t.string :source_url
t.string :logo_uri
t.timestamps
end
end
end
तो मैं मॉडल के लिए कुछ रिश्तों कहा::
सबसे पहले मैं कुछ मचान जनरेटर जो कुछ माइग्रेशन कि मैं इस मुद्दे के बिना उचित रूप में भाग गया बनाई भाग गया
class Event < ActiveRecord::Base
has_many :press_blurbs
end
class PressBlurb < ActiveRecord::Base
belongs_to :event
end
... और कहा/एक तालिका संदर्भ जोड़ने के लिए माइग्रेशन चलाया:
class AddEventRefToPressBlurbs < ActiveRecord::Migration
def change
add_column :press_blurbs, :event, :reference
end
end
फिर भी, जब मैं देखता हूं
# Could not dump table "events" because of following NoMethodError
# undefined method `[]' for nil:NilClass
# Could not dump table "press_blurbs" because of following NoMethodError
# undefined method `[]' for nil:NilClass
अन्य असंबंधित टेबल schema.rb बिल्कुल ठीक में दिखाई है, लेकिन इन नहीं: schema.db पर इस मैं क्या टेबल परिभाषाओं के बजाय है। कोई विचार क्या चल रहा है?
जब आप 'रेक डीबी: माइग्रेट' चलाते हैं तो स्कीमा अपडेट करता है? –
नहीं। :(फ़ाइल संस्करण संख्या के समान ही बनी हुई है। – huertanix