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'
This is in activesupport
include like this
require 'rubygems'
require 'active_support/core_ext/date/conversions'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With