Forum: Ferret highlighting with find_with_ferret

Posted by Romina Castillo (iuranchita)
on 2009-02-09 15:57
Hello!

I'm trying to highlight my search results,  but it doesn't work.-

In the model i have this:

acts_as_ferret( :fields => {
          :name => {:store => :yes , :boots => 100},
          :description => {:store => :yes , :boots => 50}
      })

...and i'm using find_with_ferret, so, in the controller i have this:

@repos = Repo.find_with_ferret(cad)

I don't know what to do in the view, because everything i try never
works.

I hope you can help me.
Thanks and I apologize by my bad english!!!!!
Posted by JT Kimbell (studbucket)
on 2009-02-12 17:27
I'm also having trouble with highlighting and would appreciate seeing an 
answer to this.

Thanks,

JT
Posted by Romina Castillo (iuranchita)
on 2009-02-12 18:41
JT Kimbell wrote:
> I'm also having trouble with highlighting and would appreciate seeing an 
> answer to this.

well, this is the solution that worked for me.
in the controller:

    def busqueda
        @cad = prepare_query(params[:query])
  @repos = Repo.find_with_ferret(@cad)
    end

in the view:
<% for repo in @repos %>
   <%= repo.highlight(@cad, :field=> :name , :pre_tag => "<strong>" , 
:post_tag=>"</strong>" %>
<% end %>

in the model:

acts_as_ferret( :fields => {:name => {:store => :yes , :boost => 2}})



my english is really bad, so i'm sorry

bye!
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.