Commit Graph

9 Commits

Author SHA1 Message Date
Carlos Antonio da Silva
040ff5b472 Fix named scope + class method example
Closes #8804 [ci skip]

Conflicts:
	activerecord/lib/active_record/scoping/named.rb
2013-01-07 21:27:41 -02:00
Evan Petrie
8dbf337e0a backport 68677ffb8298105eb9d3efa26d928dd88cc5e006 2012-09-28 14:19:31 -07:00
Andrew White
7056079761 Restore behavior of Active Record 3.2.3 scopes
A series of commits relating to preloading and scopes caused a regression.
Cloning the relation calls initialize_copy which resets a number of instance
variables to nil. Without this the scope thinks that it is already loaded
when it is called again.

Reverts the following commits:
13f1401a6c
8491740ca5
dffbb521a0

Fixes #6575, #6576 & #6577
2012-06-01 03:03:50 +01:00
Benedikt Deicke
13f1401a6c Removes caching from ActiveRecord::Core::ClassMethods#relation
The #relation method gets called in four places and the return value was instantly cloned in three of them. The only place that did not clone was ActiveRecord::Scoping::Default::ClassMethods#unscoped. This introduced a bug described in #5667 and should really clone the relation, too. This means all four places would clone the relation, so it doesn't make a lot of sense caching it in the first place.

The four places with calls to relations are:

activerecord/lib/active_record/scoping/default.rb:110:in `block in build_default_scope'"
activerecord/lib/active_record/scoping/default.rb:42:in `unscoped'"
activerecord/lib/active_record/scoping/named.rb:38:in `scoped'"
activerecord/lib/active_record/scoping/named.rb:52:in `scope_attributes'"

Conflicts:

	activerecord/lib/active_record/core.rb
2012-04-19 10:00:58 +02:00
Norman Clarke
d92166cb26 Check for nil logger 2012-04-18 14:44:32 -03:00
Xavier Noria
7a80ac0162 app code in general wants Time.current, not Time.now 2011-12-28 23:47:31 +01:00
Hendy Tanata
e149d5059b Improve doc for ActiveRecord::Base.unscoped. 2011-12-20 22:27:32 +05:30
Sergey Nartimov
04cea56d89 call scope within unscoped to prevent duplication of where values 2011-12-17 14:41:17 +03:00
Jon Leighton
2b22564c4e Move DefaultScope and NamedScope under Scoping 2011-12-15 20:45:42 +00:00