0
Started GET "/assets/reset.css?body=1" for 70.63.17.68 at Wed Oct 12 20:10:49 +0000 2011
Served asset /reset.css - 304 Not Modified (1ms)


Started GET "/assets/style.css?body=1" for 70.63.17.68 at Wed Oct 12 20:10:49 +0000 2011
Served asset /style.css - 304 Not Modified (0ms)


Started GET "/assets/application.css?body=1" for 70.63.17.68 at Wed Oct 12 20:10:49 +0000 2011
Started asset /application.css - 304 Not Modified (0ms)


Started GET "/assets/application.js?body=1" for 70.63.17.68 at Wed Oct 12 20:10:49 +0000 2011
Served asset /application.js - 200 OK (1ms)

我想避免此消息,如果我关闭调试模式,

config.assets.debug = off  

资产文件将作为连接。

无论如何要摆脱这些消息以及资产应该提供单独的资产文件。

4

2 回答 2

1

在您的 gemfile 上使用gem 'quiet_assets'

group :development do
  gem 'sqlite3'
  gem 'quiet_assets'
end
于 2013-03-06T14:14:15.397 回答
0

配置/初始化程序/quite_assets.rb

if Rails.env.development?
  Rails.application.assets.logger = Logger.new('/dev/null')
    Rails::Rack::Logger.class_eval do
      def call_with_quiet_assets(env)
        previous_level = Rails.logger.level
        Rails.logger.level = Logger::ERROR if env['PATH_INFO'] =~ %r{^/assets/}
        call_without_quiet_assets(env)
      ensure
        Rails.logger.level = previous_level
      end
    alias_method_chain :call, :quiet_assets
  end
end
于 2013-03-06T10:30:57.303 回答