diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-03-16 15:08:38 -0700 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-03-16 15:11:00 -0700 |
commit | df735cf5b712312a161d703f2606b145ea2d3b85 (patch) | |
tree | 02339c72a2f31571bde672d00c8f2f37dfc84f67 /activerecord/lib/active_record/aggregations.rb | |
parent | 12bf636461e3aab661119ceb3a104cfb70a11666 (diff) | |
download | rails-df735cf5b712312a161d703f2606b145ea2d3b85.tar.gz rails-df735cf5b712312a161d703f2606b145ea2d3b85.tar.bz2 rails-df735cf5b712312a161d703f2606b145ea2d3b85.zip |
fisting uninitialized ivar warnings. [#4198 state:resolved]
Signed-off-by: wycats <wycats@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record/aggregations.rb')
-rw-r--r-- | activerecord/lib/active_record/aggregations.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb index 9ecf231a66..08389907ef 100644 --- a/activerecord/lib/active_record/aggregations.rb +++ b/activerecord/lib/active_record/aggregations.rb @@ -213,6 +213,11 @@ module ActiveRecord module_eval do define_method(name) do |*args| force_reload = args.first || false + + unless instance_variable_defined?("@#{name}") + instance_variable_set("@#{name}", nil) + end + if (instance_variable_get("@#{name}").nil? || force_reload) && (!allow_nil || mapping.any? {|pair| !read_attribute(pair.first).nil? }) attrs = mapping.collect {|pair| read_attribute(pair.first)} object = case constructor |