【发布时间】:2013-12-17 12:31:17
【问题描述】:
我的模型是这样的,
class Slot
include Mongoid::Document
after_save :calculate_period
field :slot, type: Array
def calculate_period
if condition
do something
end
self.slot = true
save
end
end
提交按钮后会显示这个错误, SlotsController#create 中的 SystemStackError 堆栈级别太深
而且还花费更多时间。如果我从 def calculate_period 中删除保存,则这些值不会存储 after_save 回调。
任何解决方案...!!!
【问题讨论】:
-
你在保存后保存:无限循环
标签: ruby-on-rails mongodb mongoid