has_manyな関係でも条件を設定できる
class User < ApplicationRecord
has_many :objects
end
class Object < ApplicationRecord
belongs_to :user
scope :open, -> { where(status: 0) }
end
user = User.find(999)
user.objects.open.all #<= できるんだ!?
# => SELECT `object`.* FROM `object` WHERE `object`.`user_id` = 999 AND `myobject`.`status` = 0