Add unique table names per-user

This commit is contained in:
Trevor Vallender 2024-05-28 20:22:08 +01:00
parent 3ce9081996
commit c6072a4cb7
4 changed files with 12 additions and 1 deletions

View File

@ -5,7 +5,8 @@ class Table < ApplicationRecord
belongs_to :game_system belongs_to :game_system
validates :name, presence: true, 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, validates :slug, presence: true,
length: { maximum: 100 }, length: { maximum: 100 },
uniqueness: true uniqueness: true

View File

@ -18,6 +18,7 @@
<nav> <nav>
<ul> <ul>
<% if logged_in? %> <% if logged_in? %>
<li><%= link_to t(".tables"), tables_path %></li>
<li><%= link_to t("log_out"), logout_path, data: {turbo_method: :delete} %></li> <li><%= link_to t("log_out"), logout_path, data: {turbo_method: :delete} %></li>
<% if Current.user.admin? %> <% if Current.user.admin? %>
<li><%= link_to t("administration"), admin_index_path %></li> <li><%= link_to t("administration"), admin_index_path %></li>

View File

@ -7,10 +7,14 @@ en:
not_authenticated: You need to log in to access this page. not_authenticated: You need to log in to access this page.
edit: Edit edit: Edit
delete: Delete delete: Delete
errors:
unique_table_name: you already have a table with that name
layouts: layouts:
admin: admin:
dashboard: Dashboard dashboard: Dashboard
game_systems: Game Systems game_systems: Game Systems
application:
tables: Tables
mailer: mailer:
greeting: "Hello, %{name}" greeting: "Hello, %{name}"
sign_off: | sign_off: |

5
todo.md Normal file
View File

@ -0,0 +1,5 @@
- Complete table CRUD actions
- Ensure form errors/flash show correctly
- Add players to tables
- Add characters to users/tables
- Character sheets/prototypes