Skip to content

Instantly share code, notes, and snippets.

@slawosz
Created October 6, 2016 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slawosz/2e3d8e0cef8d32218e0a665664c1b176 to your computer and use it in GitHub Desktop.
Save slawosz/2e3d8e0cef8d32218e0a665664c1b176 to your computer and use it in GitHub Desktop.
# old rails
Model.find(:all, conditions: [...], order: "...")
default_scope
named_scope
# new rails
Model.where(..).order(..).where(..)
##
default_scope :conditions => "a=b" # default_scope lambda { where("a=b") }
class Model
# self == Model
default_scope lambda { where("a=b") }
# default_scope where("a=b") # =>
# => default_scope <Relation:xyz>
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment