# Highlighting with find\_with\_ferret

**URL:** <https://www.ruby-forum.com/t/highlighting-with-find-with-ferret/159868>\
**Category:** Ferret\
**Created:** [February 9, 2009, 3:57pm UTC](https://www.ruby-forum.com/t/highlighting-with-find-with-ferret/159868 "2009-02-09T15:57:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iuranchita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/41988e/32.png) [@iuranchita](https://www.ruby-forum.com/u/iuranchita)\
**Post date:** [February 9, 2009, 3:57pm UTC](https://www.ruby-forum.com/t/highlighting-with-find-with-ferret/159868/1 "2009-02-09T15:57:48Z")

</div>

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!!!

---

<div class="post-metadata">

**Author:** ![iuranchita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/41988e/32.png) [@iuranchita](https://www.ruby-forum.com/u/iuranchita)\
**Post date:** [February 12, 2009, 5:27pm UTC](https://www.ruby-forum.com/t/highlighting-with-find-with-ferret/159868/2 "2009-02-12T17:27:51Z")

</div>

I’m also having trouble with highlighting and would appreciate seeing an  
answer to this.

Thanks,

JT

---

<div class="post-metadata">

**Author:** ![iuranchita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/41988e/32.png) [@iuranchita](https://www.ruby-forum.com/u/iuranchita)\
**Post date:** [February 12, 2009, 6:41pm UTC](https://www.ruby-forum.com/t/highlighting-with-find-with-ferret/159868/3 "2009-02-12T18:41:50Z")

</div>

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 =\> “**” ,  
:post\_tag=\>"**" %\>  
\<% end %\>

in the model:

acts\_as\_ferret( :fields =\> {:name =\> {:store =\> :yes , :boost =\> 2}})

my english is really bad, so i’m sorry

bye!
