Add token table association

This commit is contained in:
Jesse C. Fisher 2024-03-08 04:36:08 +00:00
parent 0591c25990
commit e1ba77045f
5 changed files with 13 additions and 3 deletions

View File

@ -123,6 +123,6 @@ class TablesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def table_params
params.require(:table).permit(:title)
params.require(:table).permit(:title, :token_id)
end
end

View File

@ -6,6 +6,7 @@ class Table < ActiveRecord::Base
has_many :users, through: :seats
has_many :games
has_many :players, through: :games
belongs_to :token
#TODO: Deprecated current_game_id from database.
# Instead calculate with self.current_game
#

View File

@ -2,6 +2,8 @@
= f.error_notification
.form-inputs
= f.label :token_id
= f.collection_select(:token_id, Token.all, :id, "name")
= f.input :title
.form-actions

View File

@ -0,0 +1,5 @@
class AddTokenIdToTable < ActiveRecord::Migration[7.1]
def change
add_column :tables, :token_id, :integer
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2023_12_08_165729) do
ActiveRecord::Schema[7.1].define(version: 2024_02_08_170759) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -79,7 +79,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_08_165729) do
t.integer "sluggable_id", null: false
t.string "sluggable_type", limit: 50
t.string "scope"
t.datetime "created_at", precision: nil
t.datetime "created_at"
t.index ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true
t.index ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type"
t.index ["sluggable_type", "sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_type_and_sluggable_id"
@ -228,6 +228,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_08_165729) do
t.integer "current_game_id"
t.string "skyspace_url"
t.string "slug"
t.integer "token_id"
t.index ["slug"], name: "index_tables_on_slug", unique: true
end
@ -284,6 +285,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_08_165729) do
t.integer "invitations_count", default: 0
t.string "soft_token"
t.integer "win_count", default: 0
t.integer "points"
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["invitation_token"], name: "index_users_on_invitation_token", unique: true
t.index ["invitations_count"], name: "index_users_on_invitations_count"