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/puzzle.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 app/models/puzzle.rb (limited to 'app/models/puzzle.rb') 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 -- cgit 1.4.1