LOLSRSLY

Consider yourself warned.

Debugging Redirects

Ever had a controller action issuing a redirect, but had no idea why? Instead of disabling your gems and before_filters one by one, try this:

app/controllers/application_controller.rb
1
2
3
4
5
6
    unless Rails.env.production?
      def redirect_to(options = {}, response_status = {})
        ::Rails.logger.error("Redirected by #{caller(1).first rescue "unknown"}")
        super(options, response_status)
      end
    end

Original credit to to this blog post.