Closed DiogoAlves92 closed 5 years ago
Hi, thanks for your PR! I'm not sure if it is really useful though. AR already gives you the possibility to scope associations by specifying a second argument, I thought it was something like:
class Pirate < ActiveRecord::Base
has_many :treasures, ->{ order(id: :desc) }
end
Is there a case in which it would be useful to specify a different order scope than the one provided in the association? If there is, it's fine with me to merge this in. We should add some tests for it first in that case.
Add a scope option to dup relationships.
This could be usefull, for example, to ensure that objects are created given a certain order (for example, by their ids).
Given the
treasure
model:scope :ordered, -> { order(id: :desc) }
Usage:
pirate.deep_clone include: { treasures: {}, scope: :ordered }
What do you think?