ruby-on-railsruby-on-rails-7doorkeeper

How to cancel a redirect_to and replace with render in a controller?


I have a controller action that redirects, and I want to replace the response with render.

Yes, I know. "return early".

That will not work for this use case.

I want to change the response from DoorKeeper. This controller inherits from DoorKeeper and the DoorKeeper controller calls redirect_to.

My controller looks like this:

def new
  super

  render inline: ...
end

So, I am looking for a way to cancel the call to redirect_to in super.

I tried response = ActionDispatch::Response.new, but surprisingly that did not help.


Solution

  • Contrary to popular opinion, this is quite easy to do.

    def redirect_to
    end