# 'stack level too deep' error message

**URL:** <https://www.ruby-forum.com/t/stack-level-too-deep-error-message/52217>\
**Category:** Rails\
**Created:** [January 12, 2006, 1:06am UTC](https://www.ruby-forum.com/t/stack-level-too-deep-error-message/52217 "2006-01-12T01:06:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://www.ruby-forum.com/u/dave)\
**Post date:** [January 12, 2006, 1:06am UTC](https://www.ruby-forum.com/t/stack-level-too-deep-error-message/52217/1 "2006-01-12T01:06:59Z")

</div>

Hi,

I’m trying to pull info from my company’s ldap server. I can’t use  
ActiveLDAP because our servers don’t support schema queries.

I’ve created the model and the controller can pull the information (I’ve  
verified this from the log). However, when it comes time for the view to  
query the LDAP::Entry object, I keep getting ‘stack level too deep’.

I’ve tried searching on-line (thou shalt query google before asking  
stupid questions!) and have not found anything.

Any ideas what’s going on?

Thanks,  
Dave

---

<div class="post-metadata">

**Author:** ![dave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://www.ruby-forum.com/u/dave)\
**Post date:** [January 12, 2006, 1:14am UTC](https://www.ruby-forum.com/t/stack-level-too-deep-error-message/52217/2 "2006-01-12T01:14:58Z")

</div>

Usually means your stack in a stupid loop somewhere. Inifinite  
recursion at its best. 🙂  
Hopefully its in your code where you can easily track down the problem.

---

<div class="post-metadata">

**Author:** ![dave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://www.ruby-forum.com/u/dave)\
**Post date:** [January 12, 2006, 1:19am UTC](https://www.ruby-forum.com/t/stack-level-too-deep-error-message/52217/3 "2006-01-12T01:19:26Z")

</div>

Nick S. wrote:

> Usually means your stack in a stupid loop somewhere. Inifinite  
> recursion at its best. 🙂  
> Hopefully its in your code where you can easily track down the problem.

Nope. My code’s dirt simple at this point. Fetch my ldap entry from the  
server and display.

I have some logging statements in my controller. The ldap entry object  
has data in it that I can pull out. It’s when I get to the form that I  
get these wonderful errors.

---

<div class="post-metadata">

**Author:** ![dave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://www.ruby-forum.com/u/dave)\
**Post date:** [January 14, 2006, 4:31am UTC](https://www.ruby-forum.com/t/stack-level-too-deep-error-message/52217/4 "2006-01-14T04:31:32Z")

</div>

Nick S. wrote:

> could you post some code of whats going on around this point? helps to  
> digest and see whats going on.

Here’s the Model:

class User  
def search(filter)  
LDAP::Conn.new(‘ldap.server’,389) { |conn|  
conn.search(’’,LDAP::LDAP\_SCOPE\_SUBTREE,"(&(#{filter}))") { |e|  
arr \<\< e  
}  
return arr # yeah, I know the return is redundant. It makes me feel  
better!  
end  
end

The controller:

class UserController \< ApplicationController  
def index  
user = User.new  
@array = user.search(‘emailaddress=removed\_email\_address@domain.invalid’)  
end  
end

And the view, index.rhtml

# User
Class: \<%= @array.class %\>  
cn: \<%= @array.get\_values('cn') %\>  

Ok. Here’s what’s going on. The code that went into the model works in a  
stand alone script. It fetches the data from the ldap server and will  
print any of the attributes from the ldap server.

When I try to put the code into rails, I can verify that the model gets  
the data (by using puts statements in the model or controller. The info  
prints out in the shell running scripts/server!) and so can the  
controller. The problems start when I try to use the @array.

If I just print out the class, I get LDAP::Entry object that I expect.  
When I try anything else, like the get\_values method (which works from  
the stand alone code AND from the model/controller debugging  
statements!) I get the ‘stack level too deep’ message.

Drives me nuts! And if I’m going to move any of my projects from perl to  
rails, I need to pull data from the ldap server!

Dave

---

<div class="post-metadata">

**Author:** ![dave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://www.ruby-forum.com/u/dave)\
**Post date:** [January 14, 2006, 7:54am UTC](https://www.ruby-forum.com/t/stack-level-too-deep-error-message/52217/5 "2006-01-14T07:54:29Z")

</div>

Dave,

Take a look at my post ‘rails bug ? metadata lost between page  
invocation ?’  
[Rails bug ? metadata lost between page invocation? - Rails - Ruby-Forum](http://www.ruby-forum.com/topic/51651#new)

I ended with a weird ‘stack too deep’ weird issue as, with objects  
mysteriously ‘loosing’ their methods… I don’t know… maybe it has  
nothing to do, but it does sounds strangely similar.

Try this and let me know if this works: set ‘config.cache\_classes =  
true’ in your config/environments/development.rb.

Again, maybe it is completely unrelated, but who knows…

-Didier

---

<div class="post-metadata">

**Author:** ![dave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://www.ruby-forum.com/u/dave)\
**Post date:** [January 12, 2006, 1:42am UTC](https://www.ruby-forum.com/t/stack-level-too-deep-error-message/52217/6 "2006-01-12T01:42:27Z")

</div>

could you post some code of whats going on around this point? helps to  
digest and see whats going on.

Also, would be handy to point out exactly where the code stops working  
and gets stuck. Never used the LDAP package before, so no idea if it  
could be that or not.

---

<div class="post-metadata">

**Author:** ![dave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://www.ruby-forum.com/u/dave)\
**Post date:** [January 15, 2006, 3:50pm UTC](https://www.ruby-forum.com/t/stack-level-too-deep-error-message/52217/7 "2006-01-15T15:50:02Z")

</div>

> Try this and let me know if this works: set ‘config.cache\_classes =  
> true’ in your config/environments/development.rb.

No luck. I still get the ‘stack level too deep’ error messge.

---

<div class="post-metadata">

**Author:** ![dave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://www.ruby-forum.com/u/dave)\
**Post date:** [January 15, 2006, 5:47pm UTC](https://www.ruby-forum.com/t/stack-level-too-deep-error-message/52217/8 "2006-01-15T17:47:59Z")

</div>

2006/1/14, Dave [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ```
> arr << e
> }
> return arr
> 
> ```
> 
> end  
> end

What else is there in your User class? The above code doen’t look like  
it’s valid, the Conn.new block opens with { and clses with end. There  
aren’t any alias calls in your model are there?

Douglas

---

<div class="post-metadata">

**Author:** ![dave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@dave](https://www.ruby-forum.com/u/dave)\
**Post date:** [January 16, 2006, 2:00am UTC](https://www.ruby-forum.com/t/stack-level-too-deep-error-message/52217/9 "2006-01-16T02:00:39Z")

</div>

> > end

Opps, there should be another } after the ‘return arr’ statement. Other  
than that typo in my posting, that’s it.

Dave
