views:

184

answers:

1

Hello folks. 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. Of course I am not hoping someone to solve this question straightaway, I'd just like to have a head up, a suggestion about where to look to solve this issue. Thanks in advance,
Davide

A: 

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
ez