about summary refs log tree commit diff stats
path: root/app/models/puzzle.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/puzzle.rb')
-rw-r--r--app/models/puzzle.rb14
1 files changed, 14 insertions, 0 deletions
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 @@
1class Puzzle < ApplicationRecord
2 extend Enumerize
3
4 has_many :scores
5
6 validates :data, presence: true
7
8 validates :category, presence: true
9 enumerize :category, in: [:normal, :hard, :expert], scope: :shallow
10
11 def latest?
12 Puzzle.where(category: category).order(created_at: :desc).first.id == id
13 end
14end