Sha256: 73d29d9b914c1916453efb29f757e44f8e0f8ed4e4805cbe5253e45b21e7f049

Contents?: true

Size: 577 Bytes

Versions: 3

Compression:

Stored size: 577 Bytes

Contents

module Sunrise
  module Hooks
    module FriendlyId
      module Static
        def should_generate_new_friendly_id?
          base       = send(friendly_id_config.base)
          slug_value = send(friendly_id_config.slug_column)

          # If the slug base is nil, and the slug field is nil, then we're going to leave the slug column NULL.
          return false if base.nil? && slug_value.nil?
          
          # Otherwise, if this is a new record, we're definitely going to try to create a new slug.
          slug_value.blank?
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sunrise-cms-0.4.2 lib/sunrise/hooks/friendly_id.rb
sunrise-cms-0.4.1 lib/sunrise/hooks/friendly_id.rb
sunrise-cms-0.4.0 lib/sunrise/hooks/friendly_id.rb