Module: FriendlyId::ActiveRecordAdapter::SimpleModel
- Defined in:
- lib/friendly_id/active_record_adapter/simple_model.rb
Defined Under Namespace
Modules: SimpleFinder Classes: MultipleFinder, SingleFinder
Class Method Summary collapse
Instance Method Summary collapse
-
#friendly_id ⇒ Object
(also: #best_id)
Returns the friendly_id.
-
#friendly_id_status ⇒ Object
Get the Status after the find has been performed.
-
#to_param ⇒ Object
Returns the friendly id, or if none is available, the numeric id.
Class Method Details
.included(base) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/friendly_id/active_record_adapter/simple_model.rb', line 66 def self.included(base) base.class_eval do column = friendly_id_config.column validate :validate_friendly_id, :unless => :skip_friendly_id_validations validates_presence_of column, :unless => :skip_friendly_id_validations validates_length_of column, :maximum => friendly_id_config.max_length, :unless => :skip_friendly_id_validations after_update :update_scopes extend FriendlyId::ActiveRecordAdapter::FinderMethods end end |
Instance Method Details
#friendly_id ⇒ Object Also known as: best_id
Returns the friendly_id.
83 84 85 |
# File 'lib/friendly_id/active_record_adapter/simple_model.rb', line 83 def friendly_id send friendly_id_config.column end |
#friendly_id_status ⇒ Object
Get the Status after the find has been performed.
78 79 80 |
# File 'lib/friendly_id/active_record_adapter/simple_model.rb', line 78 def friendly_id_status @friendly_id_status ||= Status.new :record => self end |
#to_param ⇒ Object
Returns the friendly id, or if none is available, the numeric id.
89 90 91 |
# File 'lib/friendly_id/active_record_adapter/simple_model.rb', line 89 def to_param (friendly_id || id).to_s end |