Ruby-on-Rails: How to get rid of “you are being redirected” page

前端 未结 4 670
孤街浪徒
孤街浪徒 2021-01-01 13:00

I am overriding Devise\'s failure response so that I can set a 401 status code. However, when the user fails to sign in, they are redirected to a page with a \"you are being

4条回答
  •  情书的邮戳
    2021-01-01 13:12

    As said by @pantulis the browser will display this standard message if the response code is not a 3xx

    To workaround this you can perform a javascript redirect:

    # example with status 500:
    render text: "", status: 500
    

    This is off-course valid only if you are sure that all your users are using javascript. If your application can be browsed by users that may have disabled javascript you should also include a noscript tag and fallback in the standard "You are being redirected" message

提交回复
热议问题