mperham / queso

Query anything!

This URL has Read+Write access

mperham (author)
Sat Aug 22 16:01:39 -0700 2009
commit  9f0cab258bf927403e16e4d3306b6f6a8a78079a
tree    969d2f54ce3093ebdbf8c5447ee286ee530111ac
parent  59f03040585ba0ea336965f063c3ba27176c01ed
queso /
README.markdown

Queso

Queso is an engine for Rails 2.3+ which adds a generic search interface for building queries on any model. See, for example, Trac's generic query interface for tickets.

It's also a delicious cheese-based foodstuff which pairs excellently with chips and Dos XX beer.

Installation

Just add Queso as a gem to your Rails 2.3 application, via config/environment.rb:

config.gem 'mperham-queso', :source => 'http://gems.github.com'

Usage

First, mark the models you will want to search as searchable. This also gives you the ability to customize the search and results UI:

class MyModel < ActiveRecord::Base
  queso_searchable

Second, add the query partial to a page in your application to display the search interface:

<%= render :partial => 'queso/query', :locals => { :model => MyModel } %>

Lastly, add a container for the query results in the HTML page:

<div id="queso_results">
  This div will be updated with the query results when the user submits the query.
</div>

Current Limitations

  • does not support joins; you can only query on columns in the target table.
  • relies on the Engine feature of Rails 2.3 so it will not work on 2.2 or earlier.

Credits

Written by Mike Perham. Follow me on Twitter.

If you use and like Queso, please recommend me at Working with Rails.