Sha256: aaa5f05e2b78b77d9e723eb6a85177efeccc90fba6ed34e9cafd47d08124aae0

Contents?: true

Size: 464 Bytes

Versions: 11

Compression:

Stored size: 464 Bytes

Contents

module Alchemy
  module Custom
    module Model
      module SlugOptimizer

        extend ActiveSupport::Concern

        included do
          validates friendly_id_config.query_field, uniqueness: {:allow_nil => true}
          before_save :prevent_wrong_slug

          private

          def prevent_wrong_slug
            self.send("#{friendly_id_config.query_field}=", normalize_friendly_id(self.slug))
          end
        end


      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
alchemy-custom-model-3.2 lib/alchemy/custom/model/slug_optimizer.rb
alchemy-custom-model-3.1.5 lib/alchemy/custom/model/slug_optimizer.rb
alchemy-custom-model-3.1.4 lib/alchemy/custom/model/slug_optimizer.rb
alchemy-custom-model-3.1.3 lib/alchemy/custom/model/slug_optimizer.rb
alchemy-custom-model-3.1.2 lib/alchemy/custom/model/slug_optimizer.rb
alchemy-custom-model-3.1.1 lib/alchemy/custom/model/slug_optimizer.rb
alchemy-custom-model-3.1.0 lib/alchemy/custom/model/slug_optimizer.rb
alchemy-custom-model-2.2.2 lib/alchemy/custom/model/slug_optimizer.rb
alchemy-custom-model-3.0.0 lib/alchemy/custom/model/slug_optimizer.rb
alchemy-custom-model-2.2.1 lib/alchemy/custom/model/slug_optimizer.rb
alchemy-custom-model-2.2.0 lib/alchemy/custom/model/slug_optimizer.rb