From bb8ec92bf0fd92cc4514d8c64553466ed0a4edae Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Wed, 23 Jan 2019 18:38:14 +0000 Subject: [PATCH] Added a default redirect when updating a match --- app/controllers/matches_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 4cca8ed..68e242a 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -27,7 +27,11 @@ class MatchesController < ApplicationController def update respond_to do |format| if @match.update(match_params) - format.html { redirect_to params[:match][:redirect_path], notice: 'Match was successfully updated.' } + if params[:match][:redirect_path] + format.html { redirect_to params[:match][:redirect_path], notice: 'Match was successfully updated.' } + else + format.html { redirect_to "/tournaments/#{@match.tournament.id}", notice: 'Match was successfully updated.' } + end format.json { head :no_content } else format.html { render action: 'edit' }