ActiveRecord::Base#default_scopes? always returning true #10107

agis opened this Issue Apr 5, 2013 · 2 comments


None yet
2 participants

agis commented Apr 5, 2013

On a newly created app, using scaffold to create a Post resource:

Post.default_scopes # => []
Post.default_scopes? # => true

Isn't this semantically wrong? It can be misleading. Instead to get the correct result one has to do something like Post.default_scopes.any?.

It happens due to the fact that default scopes are initiated on ActiveRecord::Base using class_attributes which automatically defines the predicate method to be essentially !![] in this case.

What you think? Should this be corrected? If so, I could work on a PR.


rafaelfranca commented Apr 5, 2013

This is a side effect of using class_attributes. In my opinion this method should not exist at all. Want to open a pull request to remove it?


agis commented Apr 5, 2013

@rafaelfranca Sure. Will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment