On Feb 27, 2009, at 11:29 AM, Ga Ga wrote: > How I write it in rails format? Articles.find( ????) > > SELECT *, MATCH(title, body) AGAINST('$keyword') AS score FROM > articles > WHERE MATCH(title, body) AGAINST('$keyword') ORDER BY score DESC
Obviously, you'd have to try it yourself, but: match_part = sanitize_sql(['MATCH(title, body) AGAINST(?)', keyword]) Article.find(:all, :select => "*, #{match_part} AS score", :conditions => match_part, :order => 'score DESC') I'm guessing that the $keyword is from Perl, but I've assumed that you have a local variable called keyword. Look closely at whether the conditions end up correct or if things get double-escaped in the final SQL. -Rob Rob Biedenharn http://agileconsultingllc.com r...@agileconsultingllc.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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---