morcutt
morcutt

Reputation: 3749

using .find with a regular expression

Is there anyway in ruby on rails to make a query using regexp?

Upvotes: 2

Views: 3183

Answers (1)

Peter Brown
Peter Brown

Reputation: 51717

I think it might depend on the database. I know in MySQL you can do something like:

Model.find(:conditions => "field REGEXP '.*'")

if you want a true regex, or you can use the LIKE syntax for similar string matching.

While it doesn't have regex, there's also a gem called MetaWhere that provides more advanced finder functionality.

Upvotes: 6

Related Questions