Sha256: b2a79bee247b889b9bc90ce51195ec4757e78e6b72639c52fb980a1b7f2df622
Contents?: true
Size: 487 Bytes
Versions: 14
Compression:
Stored size: 487 Bytes
Contents
# frozen_string_literal: true class Category < ApplicationRecord has_many :page_categories, dependent: :destroy has_many :pages, through: :page_categories validates :name, presence: true acts_as_list before_save :set_slug scope :by_name, -> { order("name ASC") } private def set_slug self.slug = name.downcase .gsub(/[^\w\s]/, "") .split(/[^\w\d\-]+/) .compact .join("-") end end
Version data entries
14 entries across 14 versions & 1 rubygems