#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

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New ticket Create new ticket

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

Pages