Slide 38
Slide 38 text
良くない例 activemodel-associations
の場合
モンキーパッチで非公開API
弄りまくり
module AssociationScopeExtension
if ActiveRecord.version >= Gem::Version.new("5.0.0.beta")
def add_constraints(scope, owner, association_klass, refl, c
if refl.options[:active_model]
target_ids = refl.options[:target_ids]
return scope.where(id: owner[target_ids])
end
super
end
else
# for 4.2.x
end
end