Ruby on rails 3.2 如何在开发模式中避免资产消息

Ruby on rails 3.2 如何在开发模式中避免资产消息,ruby-on-rails-3.2,asset-pipeline,Ruby On Rails 3.2,Asset Pipeline,我希望避免此消息,如果我关闭调试模式 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 Se

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

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/initializers/quite_assets.rb

config.assets.debug = off  

在您的gem文件上使用
gem'quiet\u assets'

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
group :development do
  gem 'sqlite3'
  gem 'quiet_assets'
end