Query Builder plugin
Plugin details
Documentation
Install the plugin:
ruby script/plugin install http://railsexpress.de/svn/plugins/query_builder/trunk/
Example:
class Recipe define_finder :find_all_of_user, :all, :conditions => 'user = :user AND priv < :priv' end
This defines a query method which can be called like so:
Recipe.find_all_of_user :user => 'martin', :priv => 1
This call is equivalent to
Recipe.find :all, :conditions => ['user = :user AND priv < :priv', {:user => 'martin', :priv => 1}]
If options[:positional] is not +nil+ or +false+, the created query method will use positional paramaters instead of a hash. In this case, arguments are created in the order of appearance on the parameters passed to define_finder. Therefore
define_finder :find_all_of_user, :all, :conditions => 'user = :user AND priv < :priv', :positional => true
will create a query method with parameters +user+ and +priv+, which can be called like so:
Recipes.find_all_of_user('martin', 1)
Further Documentation
There is currently no advanced documentation for this plugin.
New documentationEdit plugin | (0 older versions) | Last edited by: hardway, about 1 year ago

