From 141f8b1a7e42928e94cccd0c8f89fdd56f8e2efe Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 28 Oct 2023 17:32:45 -0400 Subject: created puzzle and score tables --- app/models/wittle/puzzle.rb | 12 ++++++++++++ app/models/wittle/score.rb | 8 ++++++++ 2 files changed, 20 insertions(+) create mode 100644 app/models/wittle/puzzle.rb create mode 100644 app/models/wittle/score.rb (limited to 'app/models') diff --git a/app/models/wittle/puzzle.rb b/app/models/wittle/puzzle.rb new file mode 100644 index 0000000..e118d8a --- /dev/null +++ b/app/models/wittle/puzzle.rb @@ -0,0 +1,12 @@ +module Wittle + class Puzzle < ApplicationRecord + extend Enumerize + + has_many :scores + + validates :data, presence: true + + validates :category, presence: true + enumerize :category, in: [:normal, :hard, :expert], scope: :shallow + end +end diff --git a/app/models/wittle/score.rb b/app/models/wittle/score.rb new file mode 100644 index 0000000..be00fda --- /dev/null +++ b/app/models/wittle/score.rb @@ -0,0 +1,8 @@ +module Wittle + class Score < ApplicationRecord + belongs_to :puzzle + + validates :name, presence: true + validates :ip, presence: true + end +end -- cgit 1.4.1