Rails 4 default scope

Should be only: class Ticket < ActiveRecord::Base default_scope -> { order(:external_updated_at) } end default_scope accept a block, lambda is necessary for scope(), because there are 2 parameters, name and block: class Shirt < ActiveRecord::Base scope :red, -> { where(color: ‘red’) } end

Why is using the rails default_scope often recommend against?

Problem 1 Lets consider the basic example: class Post < ActiveRecord::Base default_scope { where(published: true) } end The motivation to make the default published: true, might be to make sure you have to be explict when wanting to show unpublished (private) posts. So far so good. 2.1.1 :001 > Post.all Post Load (0.2ms) SELECT “posts”.* … Read more