Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #5722 from kennyj/some_refactor_for_association

Some refactor for association.
  • Loading branch information...
commit 65be11ffecdf58e6b69fa84ea3547cd3201d2329 2 parents eda65f3 + 1e417d5
Jon Leighton authored April 12, 2012
8  activerecord/lib/active_record/associations/association.rb
@@ -25,10 +25,7 @@ class Association #:nodoc:
25 25
       def initialize(owner, reflection)
26 26
         reflection.check_validity!
27 27
 
28  
-        @target = nil
29 28
         @owner, @reflection = owner, reflection
30  
-        @updated = false
31  
-        @stale_state = nil
32 29
 
33 30
         reset
34 31
         reset_scope
@@ -46,6 +43,7 @@ def aliased_table_name
46 43
       def reset
47 44
         @loaded = false
48 45
         @target = nil
  46
+        @stale_state = nil
49 47
       end
50 48
 
51 49
       # Reloads the \target and returns +self+ on success.
@@ -215,10 +213,6 @@ def invertible_for?(record)
215 213
         def stale_state
216 214
         end
217 215
 
218  
-        def association_class
219  
-          @reflection.klass
220  
-        end
221  
-
222 216
         def build_record(attributes, options)
223 217
           reflection.build_association(attributes, options) do |record|
224 218
             attributes = create_scope.except(*(record.changed - [reflection.foreign_key]))
5  activerecord/lib/active_record/associations/belongs_to_association.rb
@@ -14,6 +14,11 @@ def replace(record)
14 14
         self.target = record
15 15
       end
16 16
 
  17
+      def reset
  18
+        super
  19
+        @updated = false
  20
+      end
  21
+
17 22
       def updated?
18 23
         @updated
19 24
       end
2  activerecord/lib/active_record/associations/collection_association.rb
@@ -71,7 +71,7 @@ def ids_writer(ids)
71 71
       end
72 72
 
73 73
       def reset
74  
-        @loaded = false
  74
+        super
75 75
         @target = []
76 76
       end
77 77
 

0 notes on commit 65be11f

Please sign in to comment.
Something went wrong with that request. Please try again.