wiki‎ > ‎crazy stacktraces‎ > ‎

lib/active_support/core_ext/date/calculations.rb:10:in `alias_method': undefined method `+' for class `Date' (NameError)

Short stacktrace:

activesupport-2.3.10/lib/active_support/core_ext/date/calculations.rb:10:in `alias_method': undefined method `+' for class `Date' (NameError)
from activesupport-2.3.10/lib/active_support/core_ext/date/calculations.rb:10:in `included'

How did I solve it?

It took me 8 pomodoros ;-) How long have you been looking for a solution?

It turned out that there was a file called lib/date.rb and Rails did try to load it at boot. By moving it to an initializer, it was fixed.

Legacy projects ...  

Full stacktrace:


spec spec/helpers/application_helper_spec.rb
activesupport-2.3.10/lib/active_support/core_ext/date/calculations.rb:10:in `alias_method': undefined method `+' for class `Date' (NameError)
from activesupport-2.3.10/lib/active_support/core_ext/date/calculations.rb:10:in `included'
from activesupport-2.3.10/lib/active_support/core_ext/date/calculations.rb:9:in `instance_eval'
from activesupport-2.3.10/lib/active_support/core_ext/date/calculations.rb:9:in `included'
from activesupport-2.3.10/lib/active_support/core_ext/date.rb:8:in `include'
from activesupport-2.3.10/lib/active_support/core_ext/date.rb:8
from activesupport-2.3.10/lib/active_support/core_ext.rb:8:in `require'
from activesupport-2.3.10/lib/active_support/core_ext.rb:8
from activesupport-2.3.10/lib/active_support/core_ext.rb:8:in `each'
from activesupport-2.3.10/lib/active_support/core_ext.rb:8
from activesupport-2.3.10/lib/active_support.rb:56:in `require'
from activesupport-2.3.10/lib/active_support.rb:56
from activerecord-2.3.10/lib/active_record.rb:25:in `require'
from activerecord-2.3.10/lib/active_record.rb:25
from rails-2.3.10/lib/initializer.rb:268:in `require'
from rails-2.3.10/lib/initializer.rb:268:in `require_frameworks'
from rails-2.3.10/lib/initializer.rb:268:in `each'
from rails-2.3.10/lib/initializer.rb:268:in `require_frameworks'
from rails-2.3.10/lib/initializer.rb:134:in `process'
from rails-2.3.10/lib/initializer.rb:113:in `send'
from rails-2.3.10/lib/initializer.rb:113:in `run'
from /config/environment.rb:9
from .rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from .rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /spec/spec_helper.rb:4
from .rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from .rvm/rubies/ruby-1.8.7-p302/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./spec/helpers/application_helper_spec.rb:1
from rspec-1.3.1/lib/spec/runner/example_group_runner.rb:15:in `load'
from rspec-1.3.1/lib/spec/runner/example_group_runner.rb:15:in `load_files'
from rspec-1.3.1/lib/spec/runner/example_group_runner.rb:14:in `each'
from rspec-1.3.1/lib/spec/runner/example_group_runner.rb:14:in `load_files'
from rspec-1.3.1/lib/spec/runner/options.rb:134:in `run_examples'
from rspec-1.3.1/lib/spec/runner/command_line.rb:9:in `run'
from rspec-1.3.1/bin/spec:5
from .rvm/gems/ruby-1.8.7-p302@epices/bin/spec:19:in `load'
from .rvm/gems/ruby-1.8.7-p302@epices/bin/spec:19
Comments