raghus
2007-Jan-15 19:07 UTC
Qn on exact phrase matches on a MySQL db from a RoR Controller
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? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
raghus
2007-Jan-17 23:39 UTC
Re: Qn on exact phrase matches on a MySQL db from a RoR Controller
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. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---