Forum: Ruby on Rails Qn on exact phrase matches on a MySQL db from a RoR Controll

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.
C56c078159148c1e3ac494ad8a7a74e0?d=identicon&s=25 raghus (Guest)
on 2007-01-17 20:50
(Received via mailing list)
To find all the movies made by a particular director, I have this in my

@dvd_pages, @dvds = paginate :dvds, :per_page => 10, :conditions =>
['match(director) against (?)',  params[:id].gsub('-',' ')]

My db is mysql. The problem with the above is that this finds both
Steven Spielberg and Steven Soderberg when searching for either one.

ie a URL like gets
translated to SELECT * FROM dvds WHERE (match(director) against
('Steven Spielberg'))" when what I need is SELECT * FROM dvds WHERE
(match(director) against ('"Steven Spielberg"')) ie the double quotes
around the phrase that I am trying to match exactly. Where do I put the
double quotes in my controller.rb? I tried around the ? and several
other options but none works.

Can anyone help?
C56c078159148c1e3ac494ad8a7a74e0?d=identicon&s=25 raghus (Guest)
on 2007-01-18 00:44
(Received via mailing list)
Here's a workaround that did it for me:
First set up dq_pattern = '"' + params[:id] + '"'
and then use dq_pattern where params[:id] was used

I'd like to hear if there are any other/better methods.
This topic is locked and can not be replied to.