Class: FriendlyId::ActiveRecordAdapter::SluggedModel::CachedSingleFinder
- Inherits:
-
FriendlyId::ActiveRecordAdapter::SimpleModel::SingleFinder
- Object
- FriendlyId::ActiveRecordAdapter::SimpleModel::SingleFinder
- FriendlyId::ActiveRecordAdapter::SluggedModel::CachedSingleFinder
- Includes:
- SluggedFinder
- Defined in:
- lib/friendly_id/active_record_adapter/slugged_model.rb
Overview
Performs a find for multiple friendly_ids using the cached_slug column, if available. This is significantly faster, and can be used in all circumstances unless the :scope
argument is present.
Instance Attribute Summary
Attributes included from Finders::Base
#ids, #model_class, #options, #scope
Instance Method Summary collapse
-
#column ⇒ Object
The column used to store the cached slug.
- #find ⇒ Object
Methods included from SluggedFinder
#handle_friendly_result, #slugs_included?
Methods included from FriendlyId::ActiveRecordAdapter::SimpleModel::SimpleFinder
Methods included from Finders::Single
Methods included from Finders::Base
friendly?, #initialize, unfriendly?
Instance Method Details
#column ⇒ Object
The column used to store the cached slug.
130 131 132 |
# File 'lib/friendly_id/active_record_adapter/slugged_model.rb', line 130 def column "#{table_name}.#{friendly_id_config.cache_column}" end |
#find ⇒ Object
121 122 123 124 125 126 127 |
# File 'lib/friendly_id/active_record_adapter/slugged_model.rb', line 121 def find @result = model_class.scoped().first() handle_friendly_result if friendly? @result rescue ActiveRecord::RecordNotFound SingleFinder.new(id, model_class, ).find end |