From 0929719a845897cc8567cf972e07a69a71f0fa6f Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 30 Nov 2023 13:29:08 -0500 Subject: Migrate to a full rails app --- app/models/application_record.rb | 3 +++ app/models/puzzle.rb | 14 ++++++++++++++ app/models/score.rb | 7 +++++++ app/models/wittle/application_record.rb | 5 ----- app/models/wittle/puzzle.rb | 16 ---------------- app/models/wittle/score.rb | 9 --------- 6 files changed, 24 insertions(+), 30 deletions(-) create mode 100644 app/models/application_record.rb create mode 100644 app/models/puzzle.rb create mode 100644 app/models/score.rb delete mode 100644 app/models/wittle/application_record.rb delete mode 100644 app/models/wittle/puzzle.rb delete mode 100644 app/models/wittle/score.rb (limited to 'app/models') diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 0000000..b63caeb --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + primary_abstract_class +end diff --git a/app/models/puzzle.rb b/app/models/puzzle.rb new file mode 100644 index 0000000..4f57d9c --- /dev/null +++ b/app/models/puzzle.rb @@ -0,0 +1,14 @@ +class Puzzle < ApplicationRecord + extend Enumerize + + has_many :scores + + validates :data, presence: true + + validates :category, presence: true + enumerize :category, in: [:normal, :hard, :expert], scope: :shallow + + def latest? + Puzzle.where(category: category).order(created_at: :desc).first.id == id + end +end diff --git a/app/models/score.rb b/app/models/score.rb new file mode 100644 index 0000000..1958389 --- /dev/null +++ b/app/models/score.rb @@ -0,0 +1,7 @@ +class Score < ApplicationRecord + belongs_to :puzzle + + validates :name, presence: true + validates :ip, presence: true + validates_uniqueness_of :name, scope: :puzzle_id +end diff --git a/app/models/wittle/application_record.rb b/app/models/wittle/application_record.rb deleted file mode 100644 index be1dfe5..0000000 --- a/app/models/wittle/application_record.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Wittle - class ApplicationRecord < ActiveRecord::Base - self.abstract_class = true - end -end diff --git a/app/models/wittle/puzzle.rb b/app/models/wittle/puzzle.rb deleted file mode 100644 index f9009bc..0000000 --- a/app/models/wittle/puzzle.rb +++ /dev/null @@ -1,16 +0,0 @@ -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 - - def latest? - Puzzle.where(category: category).order(created_at: :desc).first.id == id - end - end -end diff --git a/app/models/wittle/score.rb b/app/models/wittle/score.rb deleted file mode 100644 index 54d2b89..0000000 --- a/app/models/wittle/score.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Wittle - class Score < ApplicationRecord - belongs_to :puzzle - - validates :name, presence: true - validates :ip, presence: true - validates_uniqueness_of :name, scope: :puzzle_id - end -end -- cgit 1.4.1