Query Builder plugin

Plugin details

This plugin enables you to define finder methods that bypass the overhead of construct_finder_sql.

Websitehttp://railsexpress.de/blog/articles/2006/09/23/new-plugin-query_builder Repositoryhttp://railsexpress.de/svn/plugins/query_builder/trunk/ Author Dr.-Ing. Stefan Kaes Tags query LicenseMIT

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 documentation

Edit plugin | (0 older versions) | Last edited by: hardway, about 1 year ago