资 源 简 介
RAILS 2.0 READY!
Version 1.2 - released Oct 30, 2007. ChangeLog
Overview
Do you have a query conditions that look like this?
“(name like ‘tim%’) and (age < 10) and (category=’friends’ or category=’family’)”
Do you need a way to easily build these queries, with the ability to add more or less conditions based on user input?
Enter [RailsWhere]
Installation
script/plugin install http://railswhere.googlecode.com/svn/tags/railswhere
Example Usage
Simple
User.find(:all, :conditions => Where{|w| w.and "first_name like ?", "#{first_name}%" if params[:first_name] w.and "last_name like ?", "#{last_name}%" if params[:last_name] }
Nested conditions
```
w = Where.new
for field in [:first_name, :last_name, :phone, :email]
w.and("#{field} like ?", params[:s