rails/rails — pull request #12424 by Intrepidd (2013-10-02 08:55:38+00:00)
Title: Fix scope application on model creation with default_scope class method

The doc states that the developer can define its own ``default_scope`` method.

However, when doing that, the scope attributes aren't applied on a model creation.

Example :

````ruby
class DeveloperClassMethod < ActiveRecord::Base
def default_scope
where(:name => 'Adrien')
end
end

class Developer < ActiveRecord::Base
default_scope { where(:name => 'Adrien') }
end

Developer.new.name # => 'Adrien'
DeveloperClassMethod.new.name # => nil
````

This is due to the ``scope_attributes?`` method that only looks in the ``default_scopes`` array and does not call the ``default_scope`` class method if defined

I've replaced its content by ``scope_attributes.any?``, I think it's more clear this way and it does what the name of the method suggests.

I've also added a test to assess this issue.

Please let me know if what do you think of this.

Cheers,

Adrien.