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

- (Object) slug

Returns the value of attribute slug



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

def slug
  @slug
end

Instance Method Details

- (Object) find_slug

Raises:

  • (NotImplementedError)


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

def find_slug
  raise NotImplementedError
end

- (Object) friendly_id(skip_cache = false)

The friendly id.

Parameters:



58
59
60
61
62
63
# File 'lib/friendly_id/slugged.rb', line 58

def friendly_id(skip_cache = false)
  if friendly_id_config.cache_column? && !skip_cache
    friendly_id = send(friendly_id_config.cache_column)
  end
  friendly_id || (slug.to_friendly_id if slug?)
end

- (Object) friendly_id_config



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

def friendly_id_config
  self.class.friendly_id_config
end

- (Object) friendly_id_status

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

- (String) normalize_friendly_id(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:



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

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

- (Boolean) slug?

Does the instance have a slug?

Returns:

  • (Boolean)


74
75
76
# File 'lib/friendly_id/slugged.rb', line 74

def slug?
  !! slug
end