Plugins - RailsWhere
Add to favoritesA simple plugin that helps you build nested and/or criterias in SQL. Simple to use.
w = Where.new
for field in [:first_name, :last_name]
w.and('#{field} like ?', params[:search][field].to_s + '%')
end
w.and_not { |status_w|
for status in params[search][:exclude_statuses].split(',')
status_w.or 'status=?', status
end
}
User.find(:all, :conditions => w.to_s)
# conditions will receive something like this:
# '(first_name like 'tim%') AND (last_name like 'harper%') AND NOT ( (status = 'new') OR (status = 'expired'))'
http://code.google.com/p/railswhere/
http://railswhere.googlecode.com/svn/tags/railswhere
Rails' (MIT)
Searching and Queries
