Use ActiveSupport's silence_warnings method.