> Is there any way of extending ActiveRecord to do something like:
> <model_object>find_by_description_regex(/.*find this.*)   ??
>
> That is ActiveRecord support for find via use of regular expressions?
> Perhaps a plugin?  Or is there a reason this doesn't exist?

Model.find(:all, :conditions => ["column LIKE ?", "%find this%"])

Would do a simple substring search.  In some databases the above will  
*NOT* find "FIND THIS" because LIKE is case sensitive.  PostgreSQL is  
like that.  You can use ILIKE in that case, but don't know if that's  
supported elsewhere.

If you aren't worried about database agnostics you can look to see if  
your particular database support regex conditions...

For example http://www.postgresql.org/docs/8.3/static/functions-matching.html

-philip

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to