Rails 5: redirect_to :back is not working?
In earlier version of Rails (<5.0) we used redirect_to :back to go previous page. With this method we got ActionController::RedirectBackError error when HTTP_REFERRER is not present. This may happen when we refresh the page.
To fix this problem we have new method called redirect_back method as following:
redirect_back fallback_location: root_path
It will redirect to the previous path if HTTP_REFERRER found. If not found it will redirect to root path.