Links
ez_where
Categories
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
:conditions => ["article.title LIKE ? AND (authors.name = ? OR authors.name = ?)", "%Foo Title%", "Ezra", "Fab"]
Basically here is the breakdown of how we map ruby operators to SQL operators:
foo == 'bar' #=> ["foo = ?", 'bar'] foo =~ '%bar' #=> ["foo LIKE ?", '%bar'] foo <=> (1..5) #=> ["foo BETWEEN ? AND ?", 1, 5] id === [1, 2, 3, 5, 8] #=> ["id IN(?)", [1, 2, 3, 5, 8]] <, >, >=, <= et all will just work like you expect.
There are many more features to this plugin. See the extensive test cases in the plugin for all available options.
Vitals
| Home | http://brainspl.at/articles/2006/01/30/i-have-been-busy |
|---|---|
| Repository | svn://rubyforge.org//var/svn/ez-where |
| License | Rails' (MIT) |
| Tags |
18678fad0b759d1818675bdbbb206750 ace airlock am andes dest ehovint eve hathe hearmlor hiche himshathey ingrosessou kings led made mat od quithe search see shualt squirrel srael thent tre war
|
| Rating | (28 votes) |
| Owner | Ezra Zygmuntowicz & Fabien Franzen |
| Created | 22 April 2006 |

