Make-a the models
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled

This commit is contained in:
Bill Rossi 2026-02-01 19:45:29 -05:00
parent 14665a2837
commit 675181e954
25 changed files with 211 additions and 1 deletions

View File

@ -0,0 +1,13 @@
class GamesController < ApplicationController
def index
@games = Game.all
end
def show
@game = Game.find(params["id"])
clocks = @game.clocks
resources = @game.resources
morales = @game.morales
@trackers = clocks + resources + morales
end
end

View File

@ -0,0 +1,8 @@
class TrackersController < ApplicationController
def index
@clocks = Clock.all
@resources = Resource.all
@morales = Morale.all
@trackers = @clocks + @resources + @morales
end
end

5
app/models/clock.rb Normal file
View File

@ -0,0 +1,5 @@
class Clock < ApplicationRecord
def type
"clock"
end
end

6
app/models/game.rb Normal file
View File

@ -0,0 +1,6 @@
class Game < ApplicationRecord
has_many :clocks
has_many :resources
has_many :morales
has_many :text_trackers
end

5
app/models/morale.rb Normal file
View File

@ -0,0 +1,5 @@
class Morale < ApplicationRecord
def type
"morale"
end
end

5
app/models/resource.rb Normal file
View File

@ -0,0 +1,5 @@
class Resource < ApplicationRecord
def type
"resources"
end
end

View File

@ -0,0 +1,2 @@
class TextTracker < ApplicationRecord
end

View File

@ -0,0 +1,2 @@
class TextTrackerMessage < ApplicationRecord
end

View File

@ -0,0 +1,4 @@
<h1>Games</h1>
<% @games.each do |game| %>
<h2><a href="<%= game_path(game.id) %>"><%= game.name %></a></h2>
<% end %>

View File

@ -0,0 +1,4 @@
<h1><%= @game.name %></h1>
<% @trackers.each do |tracker| %>
<h2><%= tracker.name %>(<%= tracker.type %>)</h2>
<% end %>

View File

@ -0,0 +1,4 @@
<h1>Trackers</h1>
<% @trackers.each do |tracker| %>
<h2><%= tracker.name %>(<%= tracker.type %>)</h2>
<% end %>

View File

@ -11,4 +11,7 @@ Rails.application.routes.draw do
# Defines the root path route ("/") # Defines the root path route ("/")
# root "posts#index" # root "posts#index"
resources :games do
resources :trackers
end
end end

View File

@ -0,0 +1,11 @@
class CreateClocks < ActiveRecord::Migration[8.1]
def change
create_table :clocks do |t|
t.integer :game_id
t.string :name
t.integer :value
t.integer :max_value
t.timestamps
end
end
end

View File

@ -0,0 +1,11 @@
class CreateResources < ActiveRecord::Migration[8.1]
def change
create_table :resources do |t|
t.integer :game_id
t.string :name
t.integer :value
t.integer :max_value
t.timestamps
end
end
end

View File

@ -0,0 +1,12 @@
class CreateMorales < ActiveRecord::Migration[8.1]
def change
create_table :morales do |t|
t.integer :game_id
t.string :name
t.float :value
t.float :min_value
t.float :max_value
t.timestamps
end
end
end

View File

@ -0,0 +1,9 @@
class CreateTextTrackers < ActiveRecord::Migration[8.1]
def change
create_table :text_trackers do |t|
t.integer :game_id
t.string :name
t.timestamps
end
end
end

View File

@ -0,0 +1,9 @@
class CreateTextTrackerMessages < ActiveRecord::Migration[8.1]
def change
create_table :text_tracker_messages do |t|
t.integer :text_tracker_id
t.text :text
t.timestamps
end
end
end

View File

@ -0,0 +1,8 @@
class CreateGames < ActiveRecord::Migration[8.1]
def change
create_table :games do |t|
t.string :name
t.timestamps
end
end
end

49
db/schema.rb generated
View File

@ -10,5 +10,52 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[8.1].define(version: 0) do ActiveRecord::Schema[8.1].define(version: 2026_02_02_002823) do
create_table "clocks", force: :cascade do |t|
t.datetime "created_at", null: false
t.integer "game_id"
t.integer "max_value"
t.string "name"
t.datetime "updated_at", null: false
t.integer "value"
end
create_table "games", force: :cascade do |t|
t.datetime "created_at", null: false
t.string "name"
t.datetime "updated_at", null: false
end
create_table "morales", force: :cascade do |t|
t.datetime "created_at", null: false
t.integer "game_id"
t.float "max_value"
t.float "min_value"
t.string "name"
t.datetime "updated_at", null: false
t.float "value"
end
create_table "resources", force: :cascade do |t|
t.datetime "created_at", null: false
t.integer "game_id"
t.integer "max_value"
t.string "name"
t.datetime "updated_at", null: false
t.integer "value"
end
create_table "text_tracker_messages", force: :cascade do |t|
t.datetime "created_at", null: false
t.text "text"
t.integer "text_tracker_id"
t.datetime "updated_at", null: false
end
create_table "text_trackers", force: :cascade do |t|
t.datetime "created_at", null: false
t.integer "game_id"
t.string "name"
t.datetime "updated_at", null: false
end
end end

View File

@ -0,0 +1,7 @@
require "test_helper"
class ClockTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

7
test/models/game_test.rb Normal file
View File

@ -0,0 +1,7 @@
require "test_helper"
class GameTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require "test_helper"
class MoraleTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require "test_helper"
class ResourceTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require "test_helper"
class TextTrackerMessageTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

View File

@ -0,0 +1,7 @@
require "test_helper"
class TextTrackerTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end