The apply_scopes_if_necessary method will in some instances return the model itself - it seems in the latest versions of rails you can't call .each on the model without first creating a scope.
Solution would be to just call all, however in older versions of Rails this will return an array, which isn't expected. where(nil) might be more backwards compatible for now.
def apply_scopes_if_available(association)
respond_to?(:apply_scopes, true) ? apply_scopes(association.all) : association.all
end
The
apply_scopes_if_necessary
method will in some instances return the model itself - it seems in the latest versions of rails you can't call.each
on the model without first creating a scope.Solution would be to just call
all
, however in older versions of Rails this will return an array, which isn't expected.where(nil)
might be more backwards compatible for now.