# Yikes! stack level too deep

**URL:** <https://www.ruby-forum.com/t/yikes-stack-level-too-deep/175663>\
**Category:** Rails\
**Created:** [September 17, 2009, 10:33am UTC](https://www.ruby-forum.com/t/yikes-stack-level-too-deep/175663 "2009-09-17T10:33:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![windtrack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/258eb7/32.png) [@windtrack](https://www.ruby-forum.com/u/windtrack)\
**Post date:** [September 17, 2009, 10:33am UTC](https://www.ruby-forum.com/t/yikes-stack-level-too-deep/175663/1 "2009-09-17T10:33:26Z")

</div>

I’m not able to get past this… Basically I’m displaying my  
“Participant” and wish to display participant details which includes  
several partials. I’ve studied this over and over and I cannot fathom  
how an infinite loop can come from showing an object and its sub-  
objects. Feel like I’m getting nuts here. Are there other reasons  
we can get this error “stack level too deep”?

Showing participants/show.html.erb where line #63 raised:

stack level too deep

63: \<%= render :partial=\>‘messages/list’, :locals =\> { :pid =\>  
nil, :@messages =\> @participant.messages, @participant=\> @participant }  
%\>

Then if I fiddle with the file, is continues to error out on line 63,  
regardless of what it is:

```
Showing participants/show.html.erb where line #63 raised:

 stack level too deep

 Extracted source (around line #63):

 60: <hr>
 61: <p>
 62: <b>Sponsors count:</b>
 63: <%=h @participant.sponsors_count %>
 64: </p>
 65: <%= render :partial => "sponsors/list", :locals =>

```

{ :sponsors =\> @participant.sponsors, :pid =\> @participant.id}%\>  
66:

* * *

Until I comment out so many lines that there are none for it to  
complain about

```
Showing participants/show.html.erb where line #63 raised:

 stack level too deep

 Extracted source (around line #63):

 <nothing here>

```

Then I reboot webrick. Then it works fine for one hit to 'http://  
localhost:3001/participants/show", but not any subsequent  
refreshes. Perhaps its my IDE? Radrails 1.2.7.024747

---

<div class="post-metadata">

**Author:** ![windtrack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/258eb7/32.png) [@windtrack](https://www.ruby-forum.com/u/windtrack)\
**Post date:** [September 17, 2009, 11:37am UTC](https://www.ruby-forum.com/t/yikes-stack-level-too-deep/175663/2 "2009-09-17T11:37:49Z")

</div>

On Sep 17, 6:17 am, windtrack [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 63: \<%= render :partial=\>‘messages/list’, :locals =\> { :pid =\>  
> nil, :@messages =\> @participant.messages, @participant=\> @participant }  
> %\>

This use of locals looks a bit weird, but i don’t think it is the  
problem

> Then I reboot webrick. Then it works fine for one hit to 'http://  
> localhost:3001/participants/show", but not any subsequent  
> refreshes. Perhaps its my IDE? Radrails 1.2.7.024747

Unlikely. Stuff that works for one request only usually indicates that  
the code that reloads your source in between requests has got  
confused.  
One way of doing this is using require to require classes from your  
app: either don’t use require (let rails load things magically) or use  
require\_dependency as that keeps rails in the loop about what you are  
doing

Fred

---

<div class="post-metadata">

**Author:** ![windtrack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/258eb7/32.png) [@windtrack](https://www.ruby-forum.com/u/windtrack)\
**Post date:** [September 18, 2009, 8:37am UTC](https://www.ruby-forum.com/t/yikes-stack-level-too-deep/175663/3 "2009-09-18T08:37:36Z")

</div>

To add to Fred’s note, you don’t need to pass a controller class level  
variable (@participant) as a local variable to a second partial in the  
same request cycle as it is already visible.

On Sep 17, 2:35 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
