検索文字列を強調表示するために、Rails TextHelper の「ハイライト」メソッドを使用しています。
<%= simple_format highlight("Some test text", "some") %>
ただし、大文字と小文字が区別されるようです。この関数の大文字と小文字を区別しないバージョンはありますか? それとも、私が見逃しているいくつかのオプションですか?
検索文字列を強調表示するために、Rails TextHelper の「ハイライト」メソッドを使用しています。
<%= simple_format highlight("Some test text", "some") %>
ただし、大文字と小文字が区別されるようです。この関数の大文字と小文字を区別しないバージョンはありますか? それとも、私が見逃しているいくつかのオプションですか?
Du-oh! It turns out, Highlight method is already case insensitive.
I had a check before the line to see if the string includes the query text. I used the ruby .include? method for that which is not case sensitive!
<% if query && faq.answer.downcase.include?(query.downcase) %>
<%= highlight(excerpt(faq.answer, query, :radius => 100), query) %>
<% else %>
<%= truncate(faq.answer, :length => 200) %>
<% end %>
Using a downcase on the include? check made it work.