Qn on exact phrase matches on a MySQL db from a RoR Controll

To find all the movies made by a particular director, I have this in my
controller.

@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 http://mysite.com/director/steven-spielberg 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?

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs