s/redirect_to :back/redirect_back/

`redirect_to` has been removed in Rails 5.1 in favor of:

```
redirect_back(fallback_location: root_path)
```
This commit is contained in:
Ana María Martínez Gómez 2019-05-04 20:58:18 +02:00
parent ca32024268
commit 41d6fad7a5
No known key found for this signature in database
GPG key ID: EACB9B4BC80C0347
5 changed files with 6 additions and 7 deletions

View file

@ -70,7 +70,7 @@ module Admin
flash[:error] = errors_text flash[:error] = errors_text
end end
redirect_to :back redirect_back(fallback_location: root_path)
end end
private private

View file

@ -6,6 +6,6 @@ class OpenidsController < ApplicationController
def destroy def destroy
@openid.destroy @openid.destroy
redirect_to :back redirect_back(fallback_location: root_path)
end end
end end

View file

@ -104,7 +104,7 @@ class ProposalsController < ApplicationController
@event.event_schedules.destroy_all @event.event_schedules.destroy_all
end end
rescue Transitions::InvalidTransition 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 return
end end
@ -124,7 +124,7 @@ class ProposalsController < ApplicationController
begin begin
@event.confirm @event.confirm
rescue Transitions::InvalidTransition 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 return
end end

View file

@ -40,6 +40,6 @@ class SurveysController < ApplicationController
end end
end end
redirect_to :back redirect_back(fallback_location: root_path)
end end
end end

View file

@ -88,10 +88,9 @@ module ApplicationHelper
end end
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 = {}) def redirect_back_or_to(options = {}, response_status = {})
if request.env['HTTP_REFERER'] if request.env['HTTP_REFERER']
redirect_to :back redirect_back(fallback_location: root_path)
else else
redirect_to options, response_status redirect_to options, response_status
end end