Because apparently require 'date'
doesn't include the method hours or seconds etc:
undefined method `hours' for 5:Fixnum (NoMethodError)
Am I missing something? Is 5.seconds only something you can do in Rails? If so, what is the require statement I need to get this to work in a ruby script?
The include method has a callback which is invoked whenever a module is included into another module/class - the included method. It is executed in the context of the mixin module and should be defined there. Its signature is self. included(base) where base is the target class.
Old question, but for the googlers like me:
require 'active_support/time'
For gem version 3.2.11, anyway.
The following works for me
irb >> require 'active_support' => true >> 5.hours => 18000 seconds
Depending on your environment and rails version you may need to require 'rubygems'
this should be done before the require 'active_support'
line.
You may also have to require 'activesupport'
instead of active_support if you have an older version of rails.
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