acts_as_paranoid is making me crazy

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:

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.

Chris Olsen 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.

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

Chris Olsen 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.