Class: FriendlyId::ActiveRecordAdapter::SluggedModel::CachedSingleFinder

Inherits:
FriendlyId::ActiveRecordAdapter::SimpleModel::SingleFinder show all
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

Methods included from SluggedFinder

#handle_friendly_result, #slugs_included?

Methods included from FriendlyId::ActiveRecordAdapter::SimpleModel::SimpleFinder

#primary_key

Methods included from Finders::Single

#friendly?, #unfriendly?

Methods included from Finders::Base

friendly?, #initialize, unfriendly?

Instance Method Details

#columnObject

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

#findObject



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(find_options).first(options)
  handle_friendly_result if friendly?
  @result
rescue ActiveRecord::RecordNotFound
  SingleFinder.new(id, model_class, options).find
end