I have Active Support 3.0.3 installed and Rails 3.0.3 with Ruby 1.8.7.
When I try to use 1.week.ago I get
NoMethodError: undefined method 'week' for 1:Fixnum
from (irb):2
The other core extensions seem to work. I tried it on a friend’s computer (same install specs and legacy versions are on his) with the same results.
What gives?
All of this is in IRB.
Since using Rails should handle this automatically I’m going to assume you’re trying to add Active Support to a non-Rails script.
Read “How to Load Core Extensions“.
Active Support’s methods got broken into smaller groups in Rails 3, so we don’t end up loading a lot of unneeded stuff with a simple
require 'activesupport'. Now we have to do things likeIf you don’t care about granularity, you can choose to load bigger chunks. If you want everything in one big gulp use…
For 1.9.2:
For 1.8.7: