From 0fa1f5aeff57b77ba80baae5677f5797953c6f26 Mon Sep 17 00:00:00 2001 From: ger619 Date: Mon, 8 Apr 2024 15:25:23 +0300 Subject: [PATCH] Added hall of fame --- app/controllers/team_controller.rb | 2 +- app/models/team.rb | 2 ++ app/views/layouts/_navbar.html.erb | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/team_controller.rb b/app/controllers/team_controller.rb index b96458c5d..6c4ca3a6a 100644 --- a/app/controllers/team_controller.rb +++ b/app/controllers/team_controller.rb @@ -21,7 +21,7 @@ def create if @team.save format.html { redirect_to team_url(@team), notice: 'Team was successfully created.' } else - format.html { redirect_to team_url, notice: 'Failure' } + format.html { render :new, status: :unprocessable_entity, notice: 'Failure' } end end end diff --git a/app/models/team.rb b/app/models/team.rb index e60c249dd..abce9a75b 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -26,6 +26,8 @@ class Team < ApplicationRecord belongs_to :user has_one_attached :image + validates :jersey_number, presence: true, uniqueness: true + def name "#{first_name} #{second_name} #{last_name}" end diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb index d3507f12c..50c807650 100644 --- a/app/views/layouts/_navbar.html.erb +++ b/app/views/layouts/_navbar.html.erb @@ -65,6 +65,9 @@
  • <%= link_to "SHOP", product_index_path %>
  • +
  • + <%= link_to "HALL OF FAME", hall_of_fames_path %> +
  • <% if current_user %>
  • <%= button_to "LOGOUT", destroy_user_session_path, method: :delete, data: { turbo_method: :delete } %> @@ -111,6 +114,9 @@
  • <%= link_to "SHOP", product_index_path %>
  • +
  • + <%= link_to "HALL OF FAME", hall_of_fames_path %> +