From c6072a4cb7b95fa25d4a44125a906b680239c8b9 Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Tue, 28 May 2024 20:22:08 +0100 Subject: [PATCH] Add unique table names per-user --- app/models/table.rb | 3 ++- app/views/layouts/application.html.erb | 1 + config/locales/en.yml | 4 ++++ todo.md | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 todo.md diff --git a/app/models/table.rb b/app/models/table.rb index 4e07726..8bfec1e 100644 --- a/app/models/table.rb +++ b/app/models/table.rb @@ -5,7 +5,8 @@ class Table < ApplicationRecord belongs_to :game_system validates :name, presence: true, - length: { maximum: 100 } + length: { maximum: 100 }, + uniqueness: { scope: :owner_id, message: I18n.t("errors.unique_table_name") } validates :slug, presence: true, length: { maximum: 100 }, uniqueness: true diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 5562422..a006677 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -18,6 +18,7 @@