在Rails 4中自动加载库文件
/lib
config/initializers/custom.rb:
RELOAD_LIBS = Dir[Rails.root + 'lib/**/*.rb'] if Rails.env.development?
config/application.rb:
# Custom directories with classes and modules you want to be autoloadable.config.autoload_paths += % W(#{config.root}/lib)config.autoload_paths += Dir["#{config.root}/lib/**/"]
LIB/Extensions.rb:
Time.class_eval do def self.milli_stamp Time.now.strftime('%Y%m%d%H%M%S%L').to_i endend
Time.milli_stamp
牧羊人nacy
慕村225694
相关分类