I was looking to add an instance dependant scope to a model’s attribute has_many configuration:
has_many :sandwiches, -> (user) { where(account_id: user.account_id) }
Unfortunately, this breaks existing usage of of the attribute nested in .includes calls.
Is it possible to define the scope optionally? As in, if an instance is available, use the scope but ignore it if not?