New plugin: query_builder
Posted 23 Sep 2006
I’ve added another plugin for you to check out: query_builder.
This plugin enables you to define finder methods that bypass the overhead of construct_finder_sql.
Inside an ActiveRecord model definition, define_finder query_name, query_type, options_hash
class Recipe
define_finder :find_all_of_user, :all,
:conditions => 'user = :user AND priv < :priv'
end
Recipe.find_all_of_user :user => 'martin', :priv => 1
Recipe.find :all, :conditions =>
[ 'user = :user AND priv < :priv',
{:user => 'martin', :priv => 1} ]
define_finder :find_all_of_user, :all,
:conditions => 'user = :user AND priv < :priv',
:positional => true
Recipes.find_all_of_user('martin', 1)
I converted one of my pages to use this style and it gained 10% more performance.
If you like this plugin, drop me a line. If you find a bug, please submit a bug report to Trac
Enjoy.