• lib 下面

  • css 的路径配置问题 at March 17, 2014

    在 application.rb 中添加

    config.assets.precompile << Rails.root.join('public', 'node')
    
  • 你可以创建一个类去继承 ActiveSupport::BufferedLogger,这样就可以调用 rails 的 log,并且还能自定义路径,什么方法都不用自己写了

    class SLogger < ActiveSupport::BufferedLogger
        def initialize(log_name = 'spider', path = "")
          log_path = File.join(Rails.root, 'log', path.to_s,  "#{log_name}.log")
          super(log_path)
        end
    
        def info(msg)
          super("[#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}] -- : #{msg}\n")
        end
        alias_method :echo, :info
      end