From 41d6fad7a51b865e369169f49de7e40d701298a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ana=20Mar=C3=ADa=20Mart=C3=ADnez=20G=C3=B3mez?= Date: Sat, 4 May 2019 20:58:18 +0200 Subject: [PATCH] s/redirect_to :back/redirect_back/ `redirect_to` has been removed in Rails 5.1 in favor of: ``` redirect_back(fallback_location: root_path) ``` --- app/controllers/admin/commercials_controller.rb | 2 +- app/controllers/openids_controller.rb | 2 +- app/controllers/proposals_controller.rb | 4 ++-- app/controllers/surveys_controller.rb | 2 +- app/helpers/application_helper.rb | 3 +-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/controllers/admin/commercials_controller.rb b/app/controllers/admin/commercials_controller.rb index 003e04bf..0680b436 100644 --- a/app/controllers/admin/commercials_controller.rb +++ b/app/controllers/admin/commercials_controller.rb @@ -70,7 +70,7 @@ module Admin flash[:error] = errors_text end - redirect_to :back + redirect_back(fallback_location: root_path) end private diff --git a/app/controllers/openids_controller.rb b/app/controllers/openids_controller.rb index 3bccba2f..82af86d0 100644 --- a/app/controllers/openids_controller.rb +++ b/app/controllers/openids_controller.rb @@ -6,6 +6,6 @@ class OpenidsController < ApplicationController def destroy @openid.destroy - redirect_to :back + redirect_back(fallback_location: root_path) end end diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index d59cc2d8..692b4db0 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -104,7 +104,7 @@ class ProposalsController < ApplicationController @event.event_schedules.destroy_all end rescue Transitions::InvalidTransition - redirect_to :back, error: "Event can't be withdrawn" + redirect_back(fallback_location: root_path, error: "Event can't be withdrawn") return end @@ -124,7 +124,7 @@ class ProposalsController < ApplicationController begin @event.confirm rescue Transitions::InvalidTransition - redirect_to :back, error: "Event can't be confirmed" + redirect_back(fallback_location: root_path, error: "Event can't be confirmed") return end diff --git a/app/controllers/surveys_controller.rb b/app/controllers/surveys_controller.rb index 5c0af57e..349bc34b 100644 --- a/app/controllers/surveys_controller.rb +++ b/app/controllers/surveys_controller.rb @@ -40,6 +40,6 @@ class SurveysController < ApplicationController end end - redirect_to :back + redirect_back(fallback_location: root_path) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 36adbb0b..c8b9acbe 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -88,10 +88,9 @@ module ApplicationHelper end end - # Same as redirect_to(:back) if there is a valid HTTP referer, otherwise redirect_to() def redirect_back_or_to(options = {}, response_status = {}) if request.env['HTTP_REFERER'] - redirect_to :back + redirect_back(fallback_location: root_path) else redirect_to options, response_status end