This project is archived and is in readonly mode.
default_scope patch
-
Paweł Kondzior
It's based on this http://dev.rubyonrails.org/ticke...
-
Paweł Kondzior
default_scope with named_scope syntaxt.
class Client < ActiveRecord::Base default_scope :order => 'name DESC' end -
Repository
- State changed from new to committed
(from [ff594b2bc94ff2a942fe6ca05672387722dee686]) Added default_scope to Base [#1381 default_scope patch state:committed] (Paweł Kondzior) http://github.com/rails/rails/co...
-
DHH
- State changed from committed to open
This actually won't work with threads because:
def scoped_methods #:nodoc: Thread.current[:"#{self}_scoped_methods"] ||= [] endSo we need to promote default_scope to a class var and change the ||= [] to ||= default_scope.dup initialize default_scope to [].
-
Repository
- State changed from open to committed
(from [ca23287b448c2e007a5c93e43e762a10e0007b7a]) Revert "Added default_scope to Base [#1381 default_scope patch state:committed] (Paweł Kondzior)" -- won't gel with threads.
This reverts commit ff594b2bc94ff2a942fe6ca05672387722dee686. http://github.com/rails/rails/co...
-
Paweł Kondzior
Thread safe version.
-
Paweł Kondzior
cattr_accessor wont work, it will fail all because it will define default_scope for ActiveRecord::Base not for Model that inherts from it. So class var isn't solution here :(
-
Repository
(from [2530d0eea8eaecd2c61f99225f050ff47973e9a0]) Added default_scope to Base [#1381 default_scope patch state:committed] (Paweł Kondzior) http://github.com/rails/rails/co...
-
Tom Stuart
This doesn't work right in combination with other named scopes because
:createis initialised tonilif:conditionsisn't specified, causing a failure whenwith_scopetries to callmergeon it. The attached patch changes the behaviour to initialise:createto{}, which fixes the problem. Test included. -
DHH
Committed the fix, Tom. Thanks.
-
Daniel Luz
The documentation is slightly out of date. This is a quick fix.
-
Michał Szajbe
When default_scope's :conditions is something like { :field => ['val1', 'val2'] } then new record's field is initialized to "['val1', 'val2']" which is not desired behaviour I think. I am not sure how it should be initialized then, though.
