This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
README
ParamsScope
===========
This plugin defines ActiveRecord::Base#params_scope(params, options = {}) and
some other relatives.
Examples
=======
class User < ActiveRecord::Base
named_scope :age, lambda{|age| {:conditions => ["age = ?", age]}}
named_scope :city, lambda{|city| {:conditions => ["city = ?", city]}}
named_scope :closed, lambda{|closed| {:conditions => ["closed = ?", closed]}}
named_order_scope :order
end
class UsersController < ApplicationController
def index
# params may be {:age => "30", :city => "Tokyo"}
@users = User.params_scope(params).find(:all, :defaults => {:closed => false})
# => User.closed(false).closed(false).age(30).city("Tokyo").find(:all)
end
end
User.params_scope(:order => ["age", "asc", "updated_at, "desc"]).find(:all)
# => User.find(:all, :order => "age ASC, updated_at DESC")
TODOs
=======
* Implicit scoping: If a given key is the name of a column, use it as a dynamic scope
* Support range paramaters in some ways.
Copyright (c) 2009 Hiroshi Saito (yakitara.com), released under the MIT license








