“堆栈级别太深”带有全球化的类似引擎的插件中出现错误

发布于 2024-08-03 22:35:51 字数 1311 浏览 2 评论 0原文

借助 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回忆追雨的时光 2024-08-10 22:35:51

查看method_missing,很可能在两个不同的类中定义了两个method_missing并导致无限循环。要解决这个问题,请添加

unless method_defined?

例如

alias_method :orig_method_missing, :method_missing 
              unless method_defined? :orig_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

unless method_defined?

e.g.

alias_method :orig_method_missing, :method_missing 
              unless method_defined? :orig_method_missing
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文