So I'm trying to do an alias_method on :rescue_action_in_public within a module, included in my controller, when an exception is raised, but I keep getting "undefined method `rescue_action_in_public' from FooController".
This is my module:
module DoSomethingToExceptions
  extend ActiveSupport::Concern
  included do
    alias_method :rescue_action_in_public_with_some_extra_thing, :rescue_action_in_public
    alias_method :rescue_action_in_public, :rescue_action_in_public_without_some_extra_thing
  end
  def rescue_action_in_public_with_some_extra_thing
    do_something
    rescue_action_in_public_without_some_extra_thing
  end
end
For testing this, I have a before_filter in my controller that calls a method that only does raise 'FooException', just to get rescue_action_in_public called. Beside that, and including this module, that's the relevant controller code involved.
I have really tried to understand how this is supposed to work. The way I assumed this would work is, rescue_action_in_public gets called "from rails" when an exception is raised, and since I'm then aliasing this method, my alias method is called instead, doing whatever it is I want to add to that process, and then I'm telling it to do rescue_action_in_public_without_some_extra_thing, which is then aliased to the original rescue_action_in_public, so the native rails process should then go on.
What am I doing wrong?
                        
rescue_action_in_publicis no longer part of the Rails API. Based on http://apidock.com/rails/ActionController/Rescue/rescue_action_in_public it existed in Rails 1.x and 2.x, but was removed in Rails 3.0.The closest equivalent in Rails 4 is probably
rescue_from, but it's meant to rescue from specific exceptions, not all exceptions.