I am currently writing a search method for my rails applications and at
the moment it works fine. I have the following in my game.rb:
def self.search(search)
if search
find(:all, :conditions => ['game_name LIKE ? OR genre LIKE ? OR
console LIKE ?', "%#{search}%", "#{search}", "#{search}"])
else
find(:all)
end
end
No that searches fine but my problem is that if there is a record in
game_name that has the words playstation in it will finish the search
there and only return that record rather than that as well as all games
that have playstation stored in console. Now I understand that is
because I have OR in my conditions but I don't know an alternative. AND
simply requires all the conditions to match or no return at all. What is
an alternative I can use to AND and OR. Help would be much appreciated.
If there is a solution that has seperate search boxes and entries then
that would be fine, I don't necessarily require the search to find it
all based on one search form.
--
Posted via http://www.ruby-forum.com/.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.