Module: FriendlyId::Slugged::Model
- Included in:
- ActiveRecordAdapter::SluggedModel
- Defined in:
- lib/friendly_id/slugged.rb
Instance Attribute Summary collapse
-
#slug ⇒ Object
Returns the value of attribute slug.
Instance Method Summary collapse
- #find_slug ⇒ Object
-
#friendly_id(skip_cache = false) ⇒ Object
The friendly id.
- #friendly_id_config ⇒ Object
-
#friendly_id_status ⇒ Object
Get the FriendlyId::Status after the find has been performed.
-
#normalize_friendly_id(string) ⇒ String
Clean up the string before setting it as the friendly_id.
-
#slug? ⇒ Boolean
Does the instance have a slug?.
Instance Attribute Details
#slug ⇒ Object
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_slug ⇒ Object
43 44 45 |
# File 'lib/friendly_id/slugged.rb', line 43 def find_slug raise NotImplementedError end |
#friendly_id(skip_cache = false) ⇒ Object
The friendly id.
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 |
#friendly_id_config ⇒ Object
47 48 49 |
# File 'lib/friendly_id/slugged.rb', line 47 def friendly_id_config self.class.friendly_id_config end |
#friendly_id_status ⇒ Object
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.
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 |
#slug? ⇒ Boolean
Does the instance have a slug?
74 75 76 |
# File 'lib/friendly_id/slugged.rb', line 74 def slug? !! slug end |