Skip to content

Commit

Permalink
Remove incorrect comment regarding #initialize_copy
Browse files Browse the repository at this point in the history
Comment added in #3164 is incorrect after reading http://dev.rubyonrails.org/ticket/7191.

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
paulgillard authored and josevalim committed Jun 23, 2010
1 parent 49f52c3 commit 4a0a640
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -1413,14 +1413,6 @@ def initialize(attributes = nil)
# as it copies the object's attributes only, not its associations. The extent of a "deep" clone is
# application specific and is therefore left to the application to implement according to its need.
def initialize_copy(other)
# Think the assertion which fails if the after_initialize callback goes at the end of the method is wrong. The
# deleted clone method called new which therefore called the after_initialize callback. It then went on to copy
# over the attributes. But if it's copying the attributes afterwards then it hasn't finished initializing right?
# For example in the test suite the topic model's after_initialize method sets the author_email_address to
# test@test.com. I would have thought this would mean that all cloned models would have an author email address
# of test@test.com. However the test_clone test method seems to test that this is not the case. As a result the
# after_initialize callback has to be run *before* the copying of the attributes rather than afterwards in order
# for all tests to pass. This makes no sense to me.
callback(:after_initialize) if respond_to_without_attributes?(:after_initialize)
cloned_attributes = other.clone_attributes(:read_attribute_before_type_cast)
cloned_attributes.delete(self.class.primary_key)
Expand Down

0 comments on commit 4a0a640

Please sign in to comment.