0

Rails 2.3 の新機能のおかげで、エンジンのようなプラグインを作成しました。これは、CMS の「製品」モジュールであり、既存の (および動作中の) モデル/コントローラーから推測されます。プラグインは easy_fckeditor と globalize (説明とタイトル フィールドがローカライズされています) に依存しており、globalized が原因ではないかと思います... update アクションを除いて、すべて正常に動作します。次のエラー メッセージが表示されます: (最初の行だけを投稿します。すべてのメッセージは 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

すべての入力フィールドを 1 つずつ削除してデバッグしようとしましたが、エラーが発生し続けます。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  

ご覧のとおり、非常に簡単です。

4

1 に答える 1

0

method_missing を見てください。2 つの異なるクラスで定義された 2 つの method_missing が無限ループを引き起こしている可能性は十分にあります。この追加を解決するために

unless method_defined?

例えば

alias_method :orig_method_missing, :method_missing 
              unless method_defined? :orig_method_missing
于 2009-08-27T13:57:08.327 に答える