Monday, 4 June 2012

backtrace_silencers to clean the development log from missing assets

# /config/initializers/backtrace_silencers.rb
Rails.backtrace_cleaner.add_silencer { |line| line =~ /lib\/action_dispatch\/middleware\/static.rb/ } if Rails.env.development?

This simple line will clean up your development log to something like this:

[FTL] 
ActionController::RoutingError (No route matches [GET] "/assets/ecoologic/rooms/room_tb.png"):
  actionpack (3.2.5) lib/action_dispatch/middleware/static.rb:62:in `call'

This is only in development (or test?) as you usually don't use the static middleware in staging or production.