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