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 ?",
"%#{search_term}%"])
  end
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.
-Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
What does the resulting SQL look like in your log?
-----Original Message-----
From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-talk@googlegroups.com] On Behalf Of infinteVerve
Sent: Tuesday, October 14, 2008 10:44 AM
To: Ruby on Rails: Talk
Subject: [Rails] Searching - weird behavior with certain letters
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 ?",
"%#{search_term}%"])
  end
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.
-Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
I am so dumb...
Of course, if there are now titles with the letter C there are no
results.
I forgot to change :conditions => ["title LIKE ?",
"%#{search_term}
%"])
to>
:conditions => ["post_body LIKE ? OR title LIKE ?",
"%#{search_term}
%", "%#{search_term}%"]
Sometimes the answer is too obvious.
On Oct 14, 1:48 pm, "Pardee, Roy"
<parde...-go57ItdSaco@public.gmane.org> wrote:> What does the resulting SQL look like in your log?
>
> -----Original Message-----
> From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
[mailto:rubyonrails-talk@googlegroups.com] On Behalf Of infinteVerve
> Sent: Tuesday, October 14, 2008 10:44 AM
> To: Ruby on Rails: Talk
> Subject: [Rails] Searching - weird behavior with certain letters
>
> 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
?",
> "%#{search_term}%"])
>   end
>
> 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.
> -Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---