#77 open

Prevent unnecessary DB access when highlight method is called on FerretResult objects

Reported by Jens | February 13th, 2010 @ 12:40 AM

This is a more general solution to the problem referred to in Ticket #158: Use of the the highlight method on a [[FerretResult]] object triggering loading of the AR model instance even when the highlighted fields can be lazy loaded.

Add the following to the top of the method_missing method in ferret_result.rb

if [:highlight, :document_number, :query_for_record].include?(method.to_sym)
  @model.send method, id, *args
elsif ...

Then add highlight, document_number, and query_for_record AAF class methods, each taking an id first parameter, and change the instance methods to call these class methods.

One other useful addition to ferret_result to prevent unnecessary AR loading is:

def [](attr) method_missing(attr) end

Comments and changes to this ticket

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