ruby on rails - can you use activerecord to find substring of a field? (quick & dirty keyword finder) -
suppose database contains field 'keywords' , sample records include: "pipe wrench" "monkey wrench" "crescent wrench" "crescent roll" "monkey bars"
is there way in activerecord find records keyword field contains substring "crescent"?
(it's quick , dirty lookup quick concept prototype)
yeah, use statement in mysql.
in rails 2.x:
table.find(:all, :conditions => ['keywords ?', '%crescent%'])
in rails 3.x:
table.where('keywords ?', '%crescent%').all
Comments
Post a Comment