# Acts\_as\_paranoid is making me crazy

**URL:** <https://www.ruby-forum.com/t/acts-as-paranoid-is-making-me-crazy/135105>\
**Category:** Rails\
**Created:** [April 17, 2008, 11:00pm UTC](https://www.ruby-forum.com/t/acts-as-paranoid-is-making-me-crazy/135105 "2008-04-17T23:00:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisolsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@chrisolsen](https://www.ruby-forum.com/u/chrisolsen)\
**Post date:** [April 17, 2008, 11:00pm UTC](https://www.ruby-forum.com/t/acts-as-paranoid-is-making-me-crazy/135105/1 "2008-04-17T23:00:17Z")

</div>

Acts\_as\_paranoid is giving me a headache when performing migrations.  
For some reason when I perform a migration I get a “stack level too  
deep” error. If I comment out the database inserts that are performed  
(countries, regions, and a base admin) it works well. Even after  
minimizing the data that is inserted on the migration to one record it  
still throws the same error.

# When running the migrate with the --trace option I get the following:

rake aborted!  
stack level too deep  
/Users/chris/Documents/Projects/Rails/my\_app/vendor/plugins/acts\_as\_paranoid/init.rb:4:in  
`belongs_to_without_deleted' /Users/chris/Documents/Projects/Rails/my_app/vendor/plugins/acts_as_paranoid/init.rb:4:in`belongs\_to\_without\_deleted’  
/Users/chris/Documents/Projects/Rails/my\_app/vendor/plugins/acts\_as\_paranoid/init.rb:4:in  
`belongs\_to’  
/Users/chris/Documents/Projects/Rails/my\_app/app/models/region.rb:2

I get the same error if I remove all the acts\_as\_paranoid calls from the  
classes that use it. Although I am error free when I remove the  
acts\_as\_paranoid plugin from the project.

Any ideas on how to fix this or suggestions for a better plugin?

Thanks

---

<div class="post-metadata">

**Author:** ![chrisolsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@chrisolsen](https://www.ruby-forum.com/u/chrisolsen)\
**Post date:** [April 18, 2008, 12:34am UTC](https://www.ruby-forum.com/t/acts-as-paranoid-is-making-me-crazy/135105/2 "2008-04-18T00:34:28Z")

</div>

I have created a rake task to do the data imports after the migration is  
complete, which works. I also created another test app and used some of  
the tables and data that _seemed_ to be causing the problem, but the  
migration worked fine, so there must be something else that is causing  
the problem.

---

<div class="post-metadata">

**Author:** ![chrisolsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@chrisolsen](https://www.ruby-forum.com/u/chrisolsen)\
**Post date:** [July 2, 2008, 5:43pm UTC](https://www.ruby-forum.com/t/acts-as-paranoid-is-making-me-crazy/135105/3 "2008-07-02T17:43:47Z")

</div>

Chris O. wrote:

> I have created a rake task to do the data imports after the migration is  
> complete, which works. I also created another test app and used some of  
> the tables and data that _seemed_ to be causing the problem, but the  
> migration worked fine, so there must be something else that is causing  
> the problem.

I had this same problem. For me it was caused by a helper I was  
including in one of my migrations. It had the following line:

require ‘config/environment’

This was causing init.rb of acts\_as\_paranoid to be called twice, and  
hence the alias\_method\_chain got screwed up and ended up pointing to  
itself. Hence the ‘stack level too deep’ error.

---

<div class="post-metadata">

**Author:** ![chrisolsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@chrisolsen](https://www.ruby-forum.com/u/chrisolsen)\
**Post date:** [July 2, 2008, 7:16pm UTC](https://www.ruby-forum.com/t/acts-as-paranoid-is-making-me-crazy/135105/4 "2008-07-02T19:16:51Z")

</div>

Chris O. wrote:

> I, most likely,  
> deleted and re-created the file with the require statement that you  
> described.

Just for clarity, it was deleting the require statement that fixed the  
problem for me.

---

<div class="post-metadata">

**Author:** ![chrisolsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c6cbf5/32.png) [@chrisolsen](https://www.ruby-forum.com/u/chrisolsen)\
**Post date:** [July 2, 2008, 5:58pm UTC](https://www.ruby-forum.com/t/acts-as-paranoid-is-making-me-crazy/135105/5 "2008-07-02T17:58:23Z")

</div>

Rob Dupuis wrote:

> I had this same problem. For me it was caused by a helper I was  
> including in one of my migrations. It had the following line:
> 
> require ‘config/environment’
> 
> This was causing init.rb of acts\_as\_paranoid to be called twice, and  
> hence the alias\_method\_chain got screwed up and ended up pointing to  
> itself. Hence the ‘stack level too deep’ error.

Thanks for the update. I don’t even remember what I did, but I was able  
to get things working again a few days after the issue. I, most likely,  
deleted and re-created the file with the require statement that you  
described.

I am sure this info will come in handy later on.

Cheers
