diff --git a/app/controllers/tables_controller.rb b/app/controllers/tables_controller.rb index a3c473d6..25ee6e11 100644 --- a/app/controllers/tables_controller.rb +++ b/app/controllers/tables_controller.rb @@ -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 diff --git a/app/models/table.rb b/app/models/table.rb index c60efe28..ba41050c 100644 --- a/app/models/table.rb +++ b/app/models/table.rb @@ -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 # diff --git a/app/views/tables/_form.html.haml b/app/views/tables/_form.html.haml index c69833d0..adb03ece 100644 --- a/app/views/tables/_form.html.haml +++ b/app/views/tables/_form.html.haml @@ -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 diff --git a/db/migrate/20240208170759_add_token_id_to_table.rb b/db/migrate/20240208170759_add_token_id_to_table.rb new file mode 100644 index 00000000..5b2ebea4 --- /dev/null +++ b/db/migrate/20240208170759_add_token_id_to_table.rb @@ -0,0 +1,5 @@ +class AddTokenIdToTable < ActiveRecord::Migration[7.1] + def change + add_column :tables, :token_id, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index b31a27f8..15d54dbc 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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"