padrino can't find active_support methods
-
14-03-2021 - |
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 ?!
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