When I uploaded the Rails app to Heroku, I got an error using heroku logs
NoMethodError (undefined method `flush' for #<Logger:0x00000005501680>):
2012-12-20T16:20:42+00:00 app[web.1]: app/controllers/application_controller.rb:19:in `block in <class:ApplicationController>'
it was because of
rescue_from 'Exception' do |ex|
Rails.logger.fatal formatted_exception(ex)
Rails.logger.flush
in ApplicationController.
How do I fix it?
Flush is a method defined on IO, which flushes the buffered output to the pipe.
Given the multi-environment setup of Heroku, they probably have their own implementation of the IO pipes, which may not have flush defined. If Flush isn’t defined, it’s a fairly safe bet you don’t need it, and it flushes automatically on receiving input.
How about
P.S.
You probably shouldn’t rescue Exception: Why is it a bad style to `rescue Exception => e` in Ruby?