views:

34

answers:

1

Hi, I have built a free text search engine in rails ,I want to highlight search word in result page where, each word in the phrase may not be adjacent to each other( that is they may be present in any part of the text content). I have tried with highlight method of ActionView::Helpers::TextHelper as

<%= highlight(content.body, @search_keywords) -%>

(Where @search_keywords has the phrase)

But this is not high lighting a phrase. Can any one help me in this.

Thanks in advance.

+1  A: 

You can pass array of words to highlight function. See here.

<%= highlight(content.body, @search_keywords.split) -%>
Voyta
Hi @voyta .Thank You very much ,It worked.
kshama