Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. # Add this file to config/initializers in a Rails 2 app
  2. ActiveRecord::Base.class_eval do
  3.  
  4. # Setup some useful generic scopes
  5. named_scope :ordered, proc{ { :order => primary_key } }
  6. named_scope :where, proc{|*conditions| { :conditions => conditions.size == 1 ? conditions.first : conditions } }
  7. named_scope :joins, proc{|joins| { :joins => Array(joins).join(' ') } }
  8. named_scope :limit, proc{|count| { :limit => count } }
  9. named_scope :offset, proc{|offset| { :offset => offset } }
  10. named_scope :order, proc{|order| { :order => order.to_s } }
  11.  
  12. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement