mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-20 22:18:18 +00:00
Redirect mats#show to no_matches if no matches
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
class MatsController < ApplicationController
|
class MatsController < ApplicationController
|
||||||
before_action :set_mat, only: [:show, :edit, :update, :destroy]
|
before_action :set_mat, only: [:show, :edit, :update, :destroy]
|
||||||
before_filter :check_access, only: [:new,:create,:update,:destroy,:edit,:show]
|
before_filter :check_access, only: [:new,:create,:update,:destroy,:edit,:show]
|
||||||
|
before_filter :check_for_matches, only: [:show]
|
||||||
|
|
||||||
# GET /mats/1
|
# GET /mats/1
|
||||||
# GET /mats/1.json
|
# GET /mats/1.json
|
||||||
@@ -91,4 +92,13 @@ class MatsController < ApplicationController
|
|||||||
redirect_to '/static_pages/not_allowed'
|
redirect_to '/static_pages/not_allowed'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def check_for_matches
|
||||||
|
if @mat
|
||||||
|
if @mat.tournament.matches.empty?
|
||||||
|
redirect_to "/tournaments/#{@tournament.id}/no_matches"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user