Plugins - RailsWhere

StarAdd to favorites

A 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'))'

Tim Harper

http://code.google.com/p/railswhere/

http://railswhere.googlecode.com/svn/tags/railswhere

Rails' (MIT)

  • Currently 5.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Searching and Queries

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?