Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Add this file to config/initializers in a Rails 2 app
- ActiveRecord::Base.class_eval do
- # Setup some useful generic scopes
- named_scope :ordered, proc{ { :order => primary_key } }
- named_scope :where, proc{|*conditions| { :conditions => conditions.size == 1 ? conditions.first : conditions } }
- named_scope :joins, proc{|joins| { :joins => Array(joins).join(' ') } }
- named_scope :limit, proc{|count| { :limit => count } }
- named_scope :offset, proc{|offset| { :offset => offset } }
- named_scope :order, proc{|order| { :order => order.to_s } }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement