class Slug

A Slug is a unique, human-friendly identifier for an ActiveRecord.

Public Instance Methods

current?() click to toggle source

Whether this slug is the most recent of its owner's slugs.

# File lib/friendly_id/active_record2/slug.rb, line 57
def current?
  sluggable.slug == self
end
is_most_recent?() click to toggle source

@deprecated Please used #current?

# File lib/friendly_id/active_record2/slug.rb, line 66
def is_most_recent?
  warn("Slug#is_most_recent? is deprecated and will be removed in FriendlyId 3.0. Please use Slug#current?")
  current?
end
outdated?() click to toggle source
# File lib/friendly_id/active_record2/slug.rb, line 61
def outdated?
  !current?
end
to_friendly_id() click to toggle source
# File lib/friendly_id/active_record2/slug.rb, line 71
def to_friendly_id
  sequence > 1 ? friendly_id_with_sequence : name
end
validate_name() click to toggle source

Raise a FriendlyId::SlugGenerationError if the slug name is blank.

# File lib/friendly_id/active_record2/slug.rb, line 76
def validate_name
  if name.blank?
    raise FriendlyId::BlankError.new("slug.name can not be blank.")
  end
end