EZ Where plugin

Plugin details

This plugin augments ActiveRecord::Base#find to add ruby like syntax for queries.

Websitehttp://brainspl.at/articles/2006/01/30/i-have-been-busy Repository svn://rubyforge.org/var/svn/ez-where Author Ezra Zygmuntowicz, Fabien Franzen Tags ActiveRecord, Search LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install  svn://rubyforge.org/var/svn/ez-where

ez_where maps ruby operators to sql ops. Like this:

articles = Article.find_where(:all, :include => :author) do |article, author|
  article.title =~ "%Foo Title%"
  author.any do
    name == 'Ezra'
    name == 'Fab'
  end
end


will result in

articles = Article.find(:all, :conditions => ["article.title LIKE ? AND (authors.name = ? OR authors.name = ?)", "%Foo Title%", "Ezra", "Fab"])


There are many more features to this plugin. See the extensive test cases in the plugin for all available options.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: maxim_kulkin, 8 months ago