Module: FriendlyId::Slugged::Model

Included in:
ActiveRecordAdapter::SluggedModel
Defined in:
lib/friendly_id/slugged.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#slugObject

Returns the value of attribute slug.



41
42
43
# File 'lib/friendly_id/slugged.rb', line 41

def slug
  @slug
end

Instance Method Details

#find_slugObject

Raises:

  • (NotImplementedError)


43
44
45
# File 'lib/friendly_id/slugged.rb', line 43

def find_slug
  raise NotImplementedError
end

#friendly_idObject

The friendly id.



57
58
59
# File 'lib/friendly_id/slugged.rb', line 57

def friendly_id
  slug.to_friendly_id if slug?
end

#friendly_id_configObject



47
48
49
# File 'lib/friendly_id/slugged.rb', line 47

def friendly_id_config
  self.class.friendly_id_config
end

#friendly_id_statusObject

Get the FriendlyId::Status after the find has been performed.



52
53
54
# File 'lib/friendly_id/slugged.rb', line 52

def friendly_id_status
  @friendly_id_status ||= Status.new(:record => self)
end

#normalize_friendly_id(string) ⇒ String

Clean up the string before setting it as the friendly_id. You can override this method to add your own custom normalization routines.

Parameters:

Returns:



65
66
67
# File 'lib/friendly_id/slugged.rb', line 65

def normalize_friendly_id(string)
  string.normalize_for!(friendly_id_config).to_s
end

#slug?Boolean

Does the instance have a slug?

Returns:

  • (Boolean)


70
71
72
# File 'lib/friendly_id/slugged.rb', line 70

def slug?
  !! slug
end