Forum: Ruby on Rails Searching - weird behavior with certain letters

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
infinteVerve (Guest)
on 2008-10-14 21:45
(Received via mailing list)
I could be going about this all wrong but here goes.

I'm using a form to search my posts

The controller has:
  def searchresults
    search_term = params['search']
    @posts_search = Post.find(:all, :conditions => ["title LIKE ?",

And in the view I have this:
<% form_tag :action => 'searchresults' do %>
<%= text_field_tag :search %>
<%= submit_tag "Search" %>
<% end %>

Most terms, even single letters return the expected results.  However,
it seems that whenever the search term contains the letters F or C, no
results are returned.  There may be other letters that do the same,
but these are the only ones I've found so far.  Any ideas to why this
is happening, or how can be fixed?

Many thanks in advance.
Roy P. (Guest)
on 2008-10-14 21:49
(Received via mailing list)
What does the resulting SQL look like in your log?
infinteVerve (Guest)
on 2008-10-14 22:06
(Received via mailing list)
I am so dumb...
Of course, if there are now titles with the letter C there are no

I forgot to change :conditions => ["title LIKE ?", "%#{search_term}
:conditions => ["post_body LIKE ? OR title LIKE ?", "%#{search_term}
%", "%#{search_term}%"]

Sometimes the answer is too obvious.
This topic is locked and can not be replied to.