Reputation: 238667
I am converting some Rails controller code to be generic Ruby code. I came across this:
expiration_date = 1.hours.from_now.utc.strftime('%Y-%m-%dT%H:%M:%S.000Z')
...and realized this is not standard Ruby. I get this error message:
undefined method `hours' for 1:Fixnum (NoMethodError)
How can I convert this to standard Ruby, or require/include the necessary libraries to make this work?
Require the ActiveSupport Numeric class extensions:
require 'rubygems'
require 'active_support/core_ext/numeric/time'
Upvotes: 9
Views: 3751
Reputation: 6653
This is in activesupport
include like this
require 'rubygems'
require 'active_support/core_ext/date/conversions'
Upvotes: 7