Sha256: a1628f0a4718a7577f722a5be074169ff989ca744458e79fb18644e8a6ffb053

Contents?: true

Size: 326 Bytes

Versions: 8

Compression:

Stored size: 326 Bytes

Contents

module Panda
  module Core
    module Sluggable
      extend ActiveSupport::Concern

      included do
        before_validation :generate_slug
        validates :slug, presence: true, uniqueness: true
      end

      private

      def generate_slug
        self.slug ||= title.to_s.parameterize
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
panda-core-0.1.6 lib/panda/core/sluggable.rb
panda-core-0.1.5 lib/panda/core/sluggable.rb
panda-core-0.1.4 lib/panda/core/sluggable.rb
panda-core-0.1.3 lib/panda/core/sluggable.rb
panda-core-0.1.2 lib/panda/core/sluggable.rb
panda-core-0.1.1 lib/panda/core/sluggable.rb
panda-core-0.1.0 lib/panda/core/sluggable.rb
panda_core-0.1.0 lib/panda/core/sluggable.rb