Sha256: 0897ef7dabbc9b49b687cb3af7b941e93cab6c0ecf8c5d748a73d7ea1c9f5592

Contents?: true

Size: 457 Bytes

Versions: 23

Compression:

Stored size: 457 Bytes

Contents

module Adminpanel
  module Friendly
    extend ActiveSupport::Concern

    included do
      extend FriendlyId

      friendly_id :slug_candidates, use: :slugged

      before_validation :make_slug_nil, if: Proc.new { |object|
        object.name_changed?
      }, prepend: true
    end

    private

      def slug_candidates
        [
          :name,
          :id
        ]
      end

      def make_slug_nil
        self.slug = nil
      end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
adminpanel-3.6.1 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.6.0 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.5.1 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.5.0 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.4.7 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.4.6 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.4.5 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.4.4 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.4.3 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.4.2 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.4.1 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.4.0 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.3.4 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.3.3 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.3.0 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.2.1 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.2.0 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.1.0 app/models/concerns/adminpanel/friendly.rb
adminpanel-3.0.0 app/models/concerns/adminpanel/friendly.rb
adminpanel-2.6.1 app/models/concerns/adminpanel/friendly.rb