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:

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:inbelongs_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

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

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.

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