Module: FriendlyId::NonSluggableInstanceMethods
- Defined in:
- lib/friendly_id/non_sluggable_instance_methods.rb
Instance Attribute Summary collapse
-
#found_using_friendly_id ⇒ Object
readonly
Returns the value of attribute found_using_friendly_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#found_using_friendly_id? ⇒ Boolean
Was the record found using one of its friendly ids?.
-
#found_using_numeric_id? ⇒ Boolean
(also: #has_better_id?)
Was the record found using its numeric id?.
-
#friendly_id ⇒ Object
(also: #best_id)
Returns the friendly_id.
-
#to_param ⇒ Object
Returns the friendly id, or if none is available, the numeric id.
Instance Attribute Details
#found_using_friendly_id ⇒ Object
Returns the value of attribute found_using_friendly_id.
7 8 9 |
# File 'lib/friendly_id/non_sluggable_instance_methods.rb', line 7 def found_using_friendly_id @found_using_friendly_id end |
Class Method Details
.included(base) ⇒ Object
3 4 5 |
# File 'lib/friendly_id/non_sluggable_instance_methods.rb', line 3 def self.included(base) base.validate :validate_friendly_id end |
Instance Method Details
#found_using_friendly_id? ⇒ Boolean
Was the record found using one of its friendly ids?
10 11 12 |
# File 'lib/friendly_id/non_sluggable_instance_methods.rb', line 10 def found_using_friendly_id? @found_using_friendly_id end |
#found_using_numeric_id? ⇒ Boolean Also known as: has_better_id?
Was the record found using its numeric id?
15 16 17 |
# File 'lib/friendly_id/non_sluggable_instance_methods.rb', line 15 def found_using_numeric_id? !@found_using_friendly_id end |
#friendly_id ⇒ Object Also known as: best_id
Returns the friendly_id.
21 22 23 |
# File 'lib/friendly_id/non_sluggable_instance_methods.rb', line 21 def friendly_id send [:method] end |
#to_param ⇒ Object
Returns the friendly id, or if none is available, the numeric id.
27 28 29 |
# File 'lib/friendly_id/non_sluggable_instance_methods.rb', line 27 def to_param (friendly_id || id).to_s end |