'stack level too deep' error message


#1

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


#2

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


#3

Nick S. wrote:

Usually means your stack in a stupid loop somewhere. Inifinite
recursion at its best. :slight_smile:
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.


#4

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


#5

Dave,

Take a look at my post ‘rails bug ? metadata lost between page
invocation ?’
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


#6

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.


#7

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.


#8

2006/1/14, Dave 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


#9

end

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

Dave