/ / Mongomapper / mongoDB: SystemStackError: स्टैक स्तर बहुत गहरा - रूबी, मोंगोमैपर, रूबी-ऑन-रेल्स -3

Mongomapper / mongoDB: SystemStackError: ढेर स्तर बहुत गहरा - रूबी, mongomapper, ruby-on-rails-3

मेरे पास एक रेल 3 मॉडल "डी" है जो दूसरे मॉडल से संबंधित है, जो बदले में एक और दो से संबंधित है, जैसे:

D belongs to C
C belongs to B
B belongs to A

मैं अपने ORM के रूप में MongoDB / Mongomapper का उपयोग कर रहा हूं।

जब मैं डी को तत्काल करने की कोशिश करता हूं, तो मुझे एक त्रुटि मिल रही है:

ruby-1.9.2-preview3 > d = D.new
SystemStackError: stack level too deep
from /Users/peter/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/irb/workspace.rb:80
Maybe IRB bug!!

मुझे यह समस्या नहीं है और अन्य तीन मॉडलों के साथ काम करना तत्काल है।

नीचे मेरे सेटअप पर अधिक विवरण हैं:

एजेंसी के पास कई गुण हैं, जिनमें कई हैंनिरीक्षण, जो कई आइटम हैं। कंट्रोलर और आईआरबी दोनों में मैं कोशिश करता हूं कि मुझे यह मिल जाए आइटम जो एक निरीक्षण दस्तावेज / उदाहरण के हैं, और प्राप्त करते हैं "स्टैक स्तर बहुत गहरा" त्रुटि।

class Agency
include MongoMapper::Document
key :name, String
timestamps!
# Assocations :::::::::::::::::::::::::::::::::::::::::::::::::::::
many :properties
end

class Property
include MongoMapper::Document
timestamps!
# Assocations :::::::::::::::::::::::::::::::::::::::::::::::::::::
belongs_to :agency
many :inspections
key :address_postcode, String
end

class Inspection
include MongoMapper::Document
timestamps!
# Assocations :::::::::::::::::::::::::::::::::::::::::::::::::::::
belongs_to :property
many :items
key :date, Date
end

class Item
include MongoMapper::Document
timestamps!
# Assocations :::::::::::::::::::::::::::::::::::::::::::::::::::::
belongs_to :inspection
key :area_comment, String
end

नियंत्रक में:

def show
@inspection = Inspection.find_by_id(params[:id])
@items = @inspection.items
puts "Inspection: #...@inspection.id}"
puts "Items: #{@items}"
respond_to do |format|
format.html # show.html.erb
format.json  { render :json => @items }
end
end

फिर, IRB में:

Loading development environment (Rails 3.0.0.beta4)
ruby-1.9.2-preview3 > inspection = Inspection.find_by_id("4c4e183d55899f3d66000002")
=> #<Inspection _id: BSON::ObjectID("4c4e183d55899f3d66000002"),
created_at: Mon, 26 Jul 2010 23:20:37 UTC +00:00, updated_at: Mon, 26
Jul 2010 23:22:04 UTC +00:00, date: nil, property_id: BSON::ObjectID("4c4e181a55899f3d66000001")>
ruby-1.9.2-preview3 > puts inspection.items
SystemStackError: stack level too deep
from /Users/peter/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/irb/
workspace.rb:80
Maybe IRB bug!!

या, ब्राउज़र में:

URL: http://localhost:3000/items/4c4e183d55899f3d66000002
Returns:
500 Internal Server Error
If you are the administrator of this website, then please read this web application"s log file and/or the web server"s log file to find out what went wrong.
while in the log console:
Started GET "/items/4c4e183d55899f3d66000002" for 127.0.0.1 at
2010-07-28 10:53:57 +1000
Processing by ItemsController#show as HTML
Parameters: {"id"=>"4c4e183d55899f3d66000002"}
Completed   in 24ms
SystemStackError (stack level too deep):
/Users/peter/.rvm/gems/ruby-1.9.2-preview3@rails300/gems/
activesupport-3.0.0.beta4/lib/active_support/callbacks.rb:419
Rendered /Users/peter/.rvm/gems/ruby-1.9.2-preview3@rails300/gems/
actionpack-3.0.0.beta4/lib/action_dispatch/middleware/templates/
rescues/_trace.erb (1.2ms)
Rendered /Users/peter/.rvm/gems/ruby-1.9.2-preview3@rails300/gems/
actionpack-3.0.0.beta4/lib/action_dispatch/middleware/templates/
rescues/_request_and_response.erb (3.6ms)
Rendered /Users/peter/.rvm/gems/ruby-1.9.2-preview3@rails300/gems/
actionpack-3.0.0.beta4/lib/action_dispatch/middleware/templates/
rescues/diagnostics.erb within rescues/layout (45.7ms)

कोई विचार? मैं क्या गलत कर रहा हूं?

धन्यवाद, पीटर

उत्तर:

जवाब के लिए 2 № 1

समस्या आइटम मॉडल के साथ थी। इसमें कुंजी ": चाबियाँ" थीं। शायद ": चाबियाँ" आरक्षित हैं, लेकिन किसी भी मामले में, जैसे ही मैंने इसका नाम बदला, समस्या हल हो गई।


जवाब के लिए 2 № 2

मैं उपयोग कर रहा था: मेरे मॉडल में मॉडल विशेषता के रूप में वर्ग जो एक आरक्षित होने के लिए हुआ था, उस विशेषता नाम में परिवर्तन ने मेरे लिए काम किया था।