mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-05-07 14:52:39 +00:00
Redirect errors on match#stat back to match#stat
This commit is contained in:
@@ -50,6 +50,7 @@ class MatchesController < ApplicationController
|
|||||||
@tournament = @match.tournament
|
@tournament = @match.tournament
|
||||||
end
|
end
|
||||||
session[:return_path] = "/tournaments/#{@tournament.id}/matches"
|
session[:return_path] = "/tournaments/#{@tournament.id}/matches"
|
||||||
|
session[:error_return_path] = "/matches/#{@match.id}/stat"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -65,8 +66,13 @@ class MatchesController < ApplicationController
|
|||||||
end
|
end
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
else
|
else
|
||||||
format.html { redirect_to session.delete(:return_path), alert: "Match did not save because: #{@match.errors.full_messages.to_s}" }
|
if session[:error_return_path]
|
||||||
format.json { render json: @match.errors, status: :unprocessable_entity }
|
format.html { redirect_to session.delete(:error_return_path), alert: "Match did not save because: #{@match.errors.full_messages.to_s}" }
|
||||||
|
format.json { render json: @match.errors, status: :unprocessable_entity }
|
||||||
|
else
|
||||||
|
format.html { redirect_to "/tournaments/#{@match.tournament.id}", alert: "Match did not save because: #{@match.errors.full_messages.to_s}" }
|
||||||
|
format.json { render json: @match.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class MatsController < ApplicationController
|
|||||||
@tournament = @match.tournament
|
@tournament = @match.tournament
|
||||||
end
|
end
|
||||||
session[:return_path] = request.original_fullpath
|
session[:return_path] = request.original_fullpath
|
||||||
|
session[:error_return_path] = request.original_fullpath
|
||||||
end
|
end
|
||||||
|
|
||||||
# GET /mats/new
|
# GET /mats/new
|
||||||
|
|||||||
Reference in New Issue
Block a user