Module: ActiveRecordCache::Core

Defined in:
lib/activerecord_cache/core.rb

Instance Method Summary collapse

Instance Method Details

#find(*args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/activerecord_cache/core.rb', line 4

def find(*args)
  # Only handle single integer ids
  return super(*args) unless use_activerecord_cache && args.length == 1 && !args.first.kind_of?(Array)

  id = args.first
  record = find_through_cache(id)

  unless record
    raise ActiveRecord::RecordNotFound, "Couldn't find #{name} with '#{primary_key}'=#{id}"
  end

  record
end