Question

In my Padrino application i'm trying to get the time 10 years from now using

10.year.from_now

I'm getting:

NoMethodError: undefined method `year' for 10:Fixnum

Any idea why ?!

Était-ce utile?

La solution

ActiveSupport is not fully loaded by default this because differently than rails Padrino aims to be small and fast.

If you use ActiveRecord a full set of ActiveSupport will be loaded otherwise you need to require (i.e. in boot.rb) your dependencies. In your case:

require 'active_support/core_ext'
require 'active_support/duration'

My suggestion is to load a full active_support set whenever is really needed.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top