#31 new

Respond to to_xml with just the local FerretResult

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

Just a suggestion...

I typically store in the Ferret index the contents of the fields that I return in the search results so that when the search engine results page is rendered, a DB lookup is not needed to render each result (using the :lazy=>[:title, :description])

When displaying results via web-services, I've added this method:

module [[ActsAsFerret]]
  class [[FerretResult]]

def to_xml(*args)
  {:model=>@model, :id=>@id, :score=>@ferret_score, :data=>@data}.to_xml(argsr0)

end end
But by default, the root of the XML doc is "acts-as-ferret/ferret-results", which causes problems because of the slash, so I do this in my controller:
 render :xml => @my_model.to_xml(:root=>'search_results') 

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