stack level too deep

Yes so you can't just exclude the current, I'm not sure but I still think that it comes from the fact that each company has_many companies relationship which leads to the recursion. This shows up on the first place where you are looking up a company to be resolved to an object. Since the class has the property parents this is trying to be resolved and therefor the line asking for Organization.where(...) shows up as the error. My guess at least...

Yes so you can't just exclude the current, I'm not sure but I still think that it comes from the fact that each company has_many companies relationship which leads to the recursion. This shows up on the first place where you are looking up a company to be resolved to an object. Since the class has the property parents this is trying to be resolved and therefor the line asking for Organization.where(...) shows up as the error. My guess at least...

There could be recursion there if any record has one of its descendents as its parent, but the OP said he commented it and still had the problem... so it's probably not what's causing this issue right now.

I wonder about what the "parents" functionality is for... if it's to allow the model to act as a nested set, I'd be inclined to use a Gem that adds that ability, rather than rolling my own...