public
Description: Rails Plugin: macros for adding attribute-specific scopes and orderings to ActiveRecord models
Homepage:
Clone URL: git://github.com/duncanbeevers/named_scope_for.git
named_scope_for / README
100644 14 lines (8 sloc) 0.384 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Macro for generating attribute-specific selector scopes.
 
Similar to find_by_attribute methods, these macros provide a more flexible scoping.
 
  class User < ActiveRecord::Base
    named_scope_for :group_id
  end
 
  User.for_group_id(10).find(:all)
 
Also provides `order_by` scope that allows you to add order constraints to a query cleanly.
 
  User.order_by('created_at DESC', 'id')