summaryrefslogtreecommitdiff
path: root/app/models/category.rb
blob: c98e64a8c0759c11f65ace3b6faf9bbf06367301 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
class Category < ActiveRecord::Base
  has_many :creations
  default_scope -> { order(:slug) }

  scope :by_slug, ->(category) do
    find_by(slug: category.downcase.parameterize)
  end

  def to_param
    slug
  end
end