Search code examples
ruby-on-railsruby-on-rails-pluginshoptoad

Disable/configure HoptoadNotifier per controller


How could I disable or configure the HoptoadNotifier per controller? Background is that I configured the notifier to report "Method not allowed" exception, eg this is raised when an action is accessed with GET instead of POST.

But I have an autocomplete controller which is scanned by bots (probably to find exploits) by sending GET requests to my controller instead of POST (with all sorts of strange parameters). So I want to disable the notifier for just this exception, this action, or this controller.

Solved: Thanks to @Tanel I did the following which seems to work:

def rescue_action_in_public exception
  if exception.is_a? ActionController::MethodNotAllowed
    rescue_action_in_public_without_hoptoad exception
  else
    super exception
  end
end

Solution

  • Perhaps overriding the rescue_action_in_public in the specific controller?

    That's the method Hoptoad uses to catch its exceptions.