मैं एक साधारण मामला है, दो मॉडल वर्गों को शामिल:(वस्तु #inspect का समर्थन नहीं करता)
class Game < ActiveRecord::Base
has_many :snapshots
def initialize(params={})
# ...
end
end
class Snapshot < ActiveRecord::Base
belongs_to :game
def initialize(params={})
# ...
end
end
इन माइग्रेशन के साथ
:
class CreateGames < ActiveRecord::Migration
def change
create_table :games do |t|
t.string :name
t.string :difficulty
t.string :status
t.timestamps
end
end
end
class CreateSnapshots < ActiveRecord::Migration
def change
create_table :snapshots do |t|
t.integer :game_id
t.integer :branch_mark
t.string :previous_state
t.integer :new_row
t.integer :new_column
t.integer :new_value
t.timestamps
end
end
end
अगर मैं में एक स्नैपशॉट उदाहरण बनाने का प्रयास सांत्वना रेल,
Snapshot.new
का उपयोग कर रहा
मिल(Object doesn't support #inspect)
अब अच्छे हिस्से के लिए। अगर मैं स्नैपशॉट.आरबी में प्रारंभिक विधि को टिप्पणी करता हूं, तो स्नैपशॉट.न्यू काम करता है। ये क्यों हो रहा है?
रेल BTW मैं उपयोग कर रहा हूँ 3.1, और रूबी 1.9.2
हालांकि यह आपकी समस्या नहीं किया गया है हो सकता है, यह ऊपर आता है जब वहाँ एक कस्टम 'विधि inspect' में उठाया एक त्रुटि है। मूल त्रुटि दिखाई नहीं दे रही है, जो परेशान हो सकती है। –