blob: 4f57d9c80b0bece15aa63a0dfbe59d2fa05cb1e5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
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
|