winton / acts_as_archive

Don't delete your records, move them to a different table
MIT License
372 stars 87 forks source link

Infinite Loop during Schema Load #5

Closed tpickett66 closed 14 years ago

tpickett66 commented 14 years ago

When doing rake db:schema:load to init a new development database, the acts_as_archive gem was the source of a stack level too deep problem:

ethan-viziteis-imac-2:therapylogs ethan$ rake db:schema:load --trace (in /Users/ethan/Documents/Rails/git/therapylogs) * Invoke db:schema:load (first_time) * Invoke environment (first_time) * Execute environment * Execute db:schema:load rake aborted! stack level too deep /Users/ethan/Documents/Rails/git/therapylogs/vendor/gems/acts_as_archive-0.2.4/lib/acts_as_archive/migration.rb:20:in method_missing_without_archive' /Users/ethan/Documents/Rails/git/therapylogs/vendor/gems/acts_as_archive-0.2.4/lib/acts_as_archive/migration.rb:20:inmethod_missing' /Users/ethan/Documents/Rails/git/therapylogs/db/schema.rb:14 /Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/activerecord/lib/active_record/schema.rb:43:in instance_eval' /Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/activerecord/lib/active_record/schema.rb:43:indefine' /Users/ethan/Documents/Rails/git/therapylogs/db/schema.rb:12 /Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:in load_without_new_constant_marking' /Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:inload' /Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/activesupport/lib/active_support/dependencies.rb:521:in new_constants_in' /Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/activesupport/lib/active_support/dependencies.rb:145:inload' /Users/ethan/Documents/Rails/git/therapylogs/vendor/rails/railties/lib/tasks/databases.rake:269 /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in call' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:insynchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in run' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in run' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31 /usr/bin/rake:19:inload' /usr/bin/rake:19 ethan-viziteis-imac-2:therapylogs ethan$

Commenting out my requirement of the gem let me build my database, so there's a workaround, but just wanted to let you know.

evizitei commented 14 years ago

This can happen when alias_method gets called more than once. I fixed it by wrapping the two alias_method lines in ActsAsArchive::Migration with

unless method_defined?(:method_missing_without_archive)
alias_method :method_missing_without_archive, :method_missing
alias_method :method_missing, :method_missing_with_archive
end

That did the trick.

winton commented 14 years ago

Merged these changes and released a new gem version. Thanks again, Ethan.