stack level too deep

Hi,

I have a SystemStackError. Here is the stack (sorry if it's a little long) :

app/models/line_item.rb:14:in `product'

app/models/line_item.rb:14:in `product'

app/controllers/store_controller.rb:188:in `redirect_to_paypal'

/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/associations/association_proxy

.rb:123:in `each'

/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/associations/association_proxy

.rb:123:in `send'

/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/associations/association_proxy

.rb:123:in `method_missing'

/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/associations/has_many_association

.rb:98:in `method_missing'

app/controllers/store_controller.rb:187:in `redirect_to_paypal'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/base.rb:1095:in `send'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/base.rb:1095:in `perform_a

ction_without_filters'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:632:in `call_fi

lter'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:638:in `call_fi

lter'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:438:in `call'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:637:in `call_fi

lter'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:638:in `call_fi

lter'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:438:in `call'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:637:in `call_fi

lter'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:638:in `call_fi

lter'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:438:in `call'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:637:in `call_fi

lter'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:638:in `call_fi

lter'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:438:in `call'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:637:in `call_fi

lter'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:619:in `perform

_action_without_benchmark'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/benchmarking.rb:66:in `per

form_action_without_rescue'

/opt/local/lib/ruby/1.8/benchmark.rb:293:in `measure'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/benchmarking.rb:66:in `per

form_action_without_rescue'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/rescue.rb:83:in `perform_a

ction'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/base.rb:430:in `send'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/base.rb:430:in `process_wi

thout_filters'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/filters.rb:624:in `process

_without_session_management_support'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/session_management.rb:114:in

`process'

/opt/local/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/base.rb:330:in `process'

/opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:41:in `dispatch'

/opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb: 113:in `handle_dispatch'

/opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb: 79:in `service'

/opt/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'

/opt/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'

/opt/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'

/opt/local/lib/ruby/1.8/webrick/server.rb:162:in `start'

/opt/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'

/opt/local/lib/ruby/1.8/webrick/server.rb:95:in `start'

/opt/local/lib/ruby/1.8/webrick/server.rb:92:in `each'

/opt/local/lib/ruby/1.8/webrick/server.rb:92:in `start'

/opt/local/lib/ruby/1.8/webrick/server.rb:23:in `start'

/opt/local/lib/ruby/1.8/webrick/server.rb:82:in `start'

/opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb: 63:in `dispatch'

/opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/ webrick.rb:59

/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'

/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'

/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/ active_support/dependencies.rb:495:in `req

uire'

/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/ active_support/dependencies.rb:342:in `new

_constants_in'

/opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/ active_support/dependencies.rb:495:in `req

uire'

/opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb: 39

/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'

/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'

script/server:3

This is the method that is being called :

  def redirect_to_paypal     create_order     more_options = Hash.new

    x = 1     @order.line_items.each do |item|       more_options["item_name_#{x}"] = item.product.title # this is the line that is causing the error       more_options["amount_#{x}"] = item.product.price       more_options["quantity_#{x}"] = item.quantity       x += 1     end

    @html = render_to_string( :partial => "switch_to_paypal", :object => @order, :locals => { :more_options => more_options } )   end

Can someone figure out what is causing this error ?

Thanks, Marc

Hi Shai,

Thanks for your advice. Unfortunately, I get the same error after having renamed my variable. I've googled the net and haven't yet found a solution.

anyone ?

I had this same problem yesterday, and it was because I was calling a variable twice and it was simply looping itself over and over. Renaming the variable worked for me. It was posting to a column in my DB, then trying to post a value to the same column, so it just continuously looped itself.

Sorry I can't be more help! Just check to be sure that you are not calling a variable and then calling it again somewhere else with different values.

--Cory

CPerry, thank you a thousand times ! I had in a LineItem model file a function :

def product   self.product end

this was causing the recursion ( I don't know why I had written this function in the first place).

Marc

Awesome, glad you found the error.

--Cory