Plugins - criteria_query

StarAdd to favorites

CriteriaQuery is an extension to the ActiveRecord find mechanism. It allows object-oriented construction of queries.

In short, it lets you write:

Person.query.name_like('name').join('address').city_like('city')

instead of

Person.find(:all, :conditions=>['people.name LIKE ? AND addresses.city LIKE ?', 'name', 'city'], :include=>[:city])

or

Person.query.name_like('name').join('address').city_like('city').join('state').name_eq('state')

instead of

Person.find(:all, :conditions=>['people.name LIKE ? AND addresses.city LIKE ? AND states.name=?', 'name', 'city', 'state'], :include=>[:city=>[:state]])

This becomes increasingly useful for more complex queries, especially if the queries need to be dynamically constructed based on user input (see the README for examples).

Criteria Queries support joins across multiple associations, as well as using the same table in multiple joins.

Max Muermann

http://www.muermann.org/ruby/criteria_query/

svn://rubyforge.org/var/svn/criteriaquery

Rails' (MIT)

  • Currently 3.8/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.
Recruiting software

Have a comment?