“堆栈级别太深”带有全球化的类似引擎的插件中出现错误
借助 Rails 2.3 的新功能,我构建了一个类似引擎的插件。它是 CMS 的“产品”模块,从先前存在的(和工作的)模型/控制器推断而来。 该插件依赖于 easy_fckeditor 和全球化(描述和标题字段已本地化),我怀疑全球化可能是罪魁祸首...... 除了更新操作之外,一切正常。 我收到以下错误消息:(仅发布第一行,所有消息都是关于 attribute_methods)
stack level too deep
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:64:in `generated_methods?'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:241:in `method_missing'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:249:in `method_missing'
为了参考,完整的错误堆栈在这里: http://pastie.org/596546
我尝试调试一一消除所有输入字段,但我不断收到错误。 fckeditor 似乎不是罪魁祸首(即使没有 fckeditor 也会出错)
这就是操作:
def update
params[:product][:term_ids] ||= []
@product = Product.find(params[:id])
respond_to do |format|
if @product.update_attributes(params[:product])
flash[:notice] = t(:Product_was_successfully_updated)
format.html { redirect_to products_path }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @product.errors, :status => :unprocessable_entity }
end
end
end
如您所见,它非常简单。
I have built an engine-like plugin thanks to the new features of Rails 2.3. It's a 'Product' module for a CMS, extrapolated from a previously existing (and working) model/controller.
The plugin relies on easy_fckeditor and on globalize (description and title field are localised), and I suspect that globalized could be the culprit here...
Everything works fine, except for the update action.
I get the following error message: (posting just the first lines, all the message is about attribute_methods)
stack level too deep
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:64:in `generated_methods?'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:241:in `method_missing'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.2/lib/active_record/attribute_methods.rb:249:in `method_missing'
For referenze, the full error stack is here: http://pastie.org/596546
I've tried to debug eliminating all the input fields, one by one, but I keep getting the error. fckeditor doesn't seem the culprit (error even without fckeditor)
This is the action:
def update
params[:product][:term_ids] ||= []
@product = Product.find(params[:id])
respond_to do |format|
if @product.update_attributes(params[:product])
flash[:notice] = t(:Product_was_successfully_updated)
format.html { redirect_to products_path }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @product.errors, :status => :unprocessable_entity }
end
end
end
As you see it's quite straightforward.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看method_missing,很可能在两个不同的类中定义了两个method_missing并导致无限循环。要解决这个问题,请添加
例如
Look at the method_missing, it is quite possible that two method_missing defined in two different class and is causing an infinite loop. to solve this add
e.g.