# stack level too deep

**URL:** <https://discuss.rubyonrails.org/t/stack-level-too-deep/15274>\
**Category:** rubyonrails-talk\
**Created:** [July 4, 2007, 8:44am UTC](https://discuss.rubyonrails.org/t/stack-level-too-deep/15274 "2007-07-04T08:44:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpalluat](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@mpalluat](https://discuss.rubyonrails.org/u/mpalluat)\
**Post date:** [July 4, 2007, 8:44am UTC](https://discuss.rubyonrails.org/t/stack-level-too-deep/15274/1 "2007-07-04T08:44:19Z")

</div>

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 :

&nbsp;&nbsp;def redirect\_to\_paypal &nbsp;&nbsp;&nbsp;&nbsp;create\_order &nbsp;&nbsp;&nbsp;&nbsp;more\_options = Hash.new

&nbsp;&nbsp;&nbsp;&nbsp;x = 1 &nbsp;&nbsp;&nbsp;&nbsp;@order.line\_items.each do |item| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;more\_options["item\_name\_#{x}"] = item.product.title # this is the line that is causing the error &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;more\_options["amount\_#{x}"] = item.product.price &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;more\_options["quantity\_#{x}"] = item.quantity &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x += 1 &nbsp;&nbsp;&nbsp;&nbsp;end

&nbsp;&nbsp;&nbsp;&nbsp;@html = render\_to\_string( :partial =\> "switch\_to\_paypal", :object =\> @order, :locals =\> { :more\_options =\> more\_options } ) &nbsp;&nbsp;end

Can someone figure out what is causing this error ?

Thanks, Marc

---

<div class="post-metadata">

**Author:** ![mpalluat](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@mpalluat](https://discuss.rubyonrails.org/u/mpalluat)\
**Post date:** [July 4, 2007, 12:16pm UTC](https://discuss.rubyonrails.org/t/stack-level-too-deep/15274/2 "2007-07-04T12:16:41Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![CPerry](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@CPerry](https://discuss.rubyonrails.org/u/CPerry)\
**Post date:** [July 4, 2007, 12:46pm UTC](https://discuss.rubyonrails.org/t/stack-level-too-deep/15274/3 "2007-07-04T12:46:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mpalluat](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@mpalluat](https://discuss.rubyonrails.org/u/mpalluat)\
**Post date:** [July 4, 2007, 3:20pm UTC](https://discuss.rubyonrails.org/t/stack-level-too-deep/15274/4 "2007-07-04T15:20:29Z")

</div>

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

def product &nbsp;&nbsp;self.product end

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

Marc

---

<div class="post-metadata">

**Author:** ![CPerry](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@CPerry](https://discuss.rubyonrails.org/u/CPerry)\
**Post date:** [July 4, 2007, 5:26pm UTC](https://discuss.rubyonrails.org/t/stack-level-too-deep/15274/5 "2007-07-04T17:26:31Z")

</div>

Awesome, glad you found the error.

--Cory
