#212 new
Lee Iverson

:find_by with cache_fu

Reported by Lee Iverson | April 28th, 2008 @ 01:56 PM

The current setup for :find_by ends up causing problems with get_caches. I've specified :find_by => :name in one of classes and was constantly puzzled when get_caches would not find perfectly valid named records.

I eventually tracked it down to fetch_cachable_data(), which loads AR records that miss the cache. It uses the :finder method which gets set to :find_by_name, but then only returns the first named record... Duh! It should be :find_all_by_name.

Changing the assignment in acts_as_cached.rb works like a charm!

  1. convert the find_by shorthand

if find_by = options.delete(:find_by)

options[:finder] = "find_all_by_#{find_by}".to_sym

options[:cache_id] = find_by

end

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket

Attachments