Do "like" queries with ActiveRecord in Rails 2.x and 3.x? -


I'm querying Rail 3.x like this

  Speaker.where ("Name '% yson%' ')   

but I would love to avoid DB specific code. What is the right way to do this?

If this is a way of doing it in Rail 2.x, then it will also help.

You can use it.

  & gt; T [: name]. Matches ('% lower'). To_sql = & gt; "\" Product \ ". \" Name \ "such as '% lower'"   

will have a real use in a query:

  speaker.jet ( Speaker.rel_table [: name]. Matches ('% lower'))    

Comments