只想说我确实在谷歌上详细搜索了这个主题,但找不到任何适用于我自己的用例的东西。
我有一个简单的小广告服务器。有一个模型Ad
,两个嵌入式模型称为Impression
and Click
- 像这样:
class Ad
include MongoMapper::Document
key :name, String
key :image, String
key :url, String
has_many :clicks
has_many :impressions
end
class Click
include MongoMapper::EmbeddedDocument
key :ip, String
timestamps!
end
class Impression
include MongoMapper::EmbeddedDocument
key :ip, String
timestamps!
end
这是我得到的错误:
SystemStackError - stack level too deep:
/home/deployer/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/mongo_mapper-0.12.0/lib/mongo_mapper/plugins/keys.rb:194
这是发生这种情况的区域:
@ad.impressions << Impression.new({:ip => request.ip})
@ad.save
现在,我的模型中没有任何回调,这就是很多人发生此错误的原因。
有人有任何见解吗?
谢谢。