education/classroom

View on GitHub
app/models/concerns/sluggable.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

module Sluggable
  extend ActiveSupport::Concern

  included do
    before_validation :slugify
  end

  def slugify
    self.slug = name_for_slug.parameterize
  end

  def to_param
    slug
  end

  private

  def name_for_slug
    title
  end
end