I'm writing a Ruby script that involves date comparisons.
To keep it readable, I'd like to do things like 1.day.ago. I thought it would be as easy as adding gem 'activesupport' to my gemfile and requiring require 'active_support'. But that doesn't work.
I've gone further:
require "active_support/core_ext/date/calculations"
require "active_support/core_ext/integer/time"
require "active_support/core_ext/time"
But I'm not quite there:
1.day.ago
#NameError: uninitialized constant ActiveSupport::IsolatedExecutionState
#
# ::ActiveSupport::IsolatedExecutionState[:time_zone] || zone_default
…I'm not sure what else I need to require. How do I use all of active record's date/time methods in my vanilla ruby script?
You just need to include
ActiveSupport::IsolatedExecutionStatee.g.Why this is not required in "active_support/core_ext/time/zones", I can't say as I feel like it should be to avoid this issue.
If you really want to include all of
activesupportyou were very close however the actual require statement isrequire 'active_support/all'The contents of this file are simply: