From 4e370613f09c7460320165cc8deadeedf828b85d Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Sun, 14 Mar 2010 17:43:59 -0700 Subject: [PATCH] cleaning up many more warnings in activerecord [#4180 state:resolved] --- activerecord/lib/active_record/base.rb | 10 ++++++++-- .../lib/active_record/dynamic_finder_match.rb | 3 +++ activerecord/lib/active_record/migration.rb | 4 +++- activerecord/lib/active_record/relation.rb | 3 +++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 0ce876d..1488d9f 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1042,6 +1042,9 @@ module ActiveRecord #:nodoc: object.instance_variable_set(:'@attributes', record) object.instance_variable_set(:'@attributes_cache', {}) object.instance_variable_set(:@new_record, false) + object.instance_variable_set(:@readonly, false) + object.instance_variable_set(:@destroyed, false) + object.instance_variable_set(:@marked_for_destruction, false) object.send(:_run_find_callbacks) object.send(:_run_initialize_callbacks) @@ -1508,6 +1511,9 @@ module ActiveRecord #:nodoc: @attributes_cache = {} @new_record = true @readonly = false + @destroyed = false + @marked_for_destruction = false + ensure_proper_type if scope = self.class.send(:current_scoped_methods) @@ -1599,12 +1605,12 @@ module ActiveRecord #:nodoc: # Returns true if this object hasn't been saved yet -- that is, a record for the object doesn't exist yet; otherwise, returns false. def new_record? - @new_record || false + @new_record end # Returns true if this object has been destroyed, otherwise returns false. def destroyed? - @destroyed || false + @destroyed end # Returns if the record is persisted, i.e. it's not a new record and it was not destroyed. diff --git a/activerecord/lib/active_record/dynamic_finder_match.rb b/activerecord/lib/active_record/dynamic_finder_match.rb index 8f9f05c..fa7a194 100644 --- a/activerecord/lib/active_record/dynamic_finder_match.rb +++ b/activerecord/lib/active_record/dynamic_finder_match.rb @@ -7,6 +7,9 @@ module ActiveRecord def initialize(method) @finder = :first + @bang = false + @instantiator = nil + case method.to_s when /^find_(all_by|last_by|by)_([_a-zA-Z]\w*)$/ @finder = :last if $1 == 'last_by' diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index fd5ffc6..5825482 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -315,7 +315,9 @@ module ActiveRecord end def announce(message) - text = "#{@version} #{name}: #{message}" + version = defined?(@version) ? @version : nil + + text = "#{version} #{name}: #{message}" length = [0, 75 - text.length].max write "== %s %s" % [text, "=" * length] end diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb index 3a7ebce..1a84f70 100644 --- a/activerecord/lib/active_record/relation.rb +++ b/activerecord/lib/active_record/relation.rb @@ -18,6 +18,9 @@ module ActiveRecord @readonly_value = nil @create_with_value = nil @implicit_readonly = nil + @limit_value = nil + @offset_value = nil + @loaded = nil (ASSOCIATION_METHODS + MULTI_VALUE_METHODS).each {|v| instance_variable_set(:"@#{v}_values", [])} end -- 1.6.6