Add token table association
This commit is contained in:
parent
448fa1a0b3
commit
92b65a9101
@ -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
|
||||
|
||||
@ -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
|
||||
#
|
||||
|
||||
@ -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
|
||||
|
||||
5
db/migrate/20240208170759_add_token_id_to_table.rb
Normal file
5
db/migrate/20240208170759_add_token_id_to_table.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddTokenIdToTable < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_column :tables, :token_id, :integer
|
||||
end
|
||||
end
|
||||
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user