class Pathwright::Course < ApplicationRecord
  include Cacheable

  belongs_to :category, touch: true

  validates :name, presence: true, length: { maximum: 255 }

  scope :by_categories, ->(ids) { where(category_id: ids) if ids }

  private
    def set_cache_keys
      self.cache_keys = ["pathwright/courses/#{category_id}"]
    end
end
