Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Update ActiveRecord::Base#initialize_dup override in line with ActiveRec... #123

Merged
merged 1 commit into from

2 participants

@tism

...ord::Base 3.2.5+

initialize_attributes is included from ActiveRecord::AttributeMethods::Serialization and since 3.2.5 accepts
an options hash which can control whether or not the attributes are initialized serialized or unserialized.

This fixes issue #119, however it will make things incompatible with ActiveRecord < 3.2.5. Not sure how version support should be handled here.

@tism tism Update ActiveRecord::Base#initialize_dup override in line with Active…
…Record::Base 3.2.5+

initialize_attributes is included from ActiveRecord::AttributeMethods::Serialization and since 3.2.5 accepts
an options hash which can control whether or not the attributes are initialized serialized or unserialized.
1bb0a86
@cfis cfis merged commit 7a39fb3 into composite-primary-keys:master
@cfis
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 25, 2012
  1. @tism

    Update ActiveRecord::Base#initialize_dup override in line with Active…

    tism authored
    …Record::Base 3.2.5+
    
    initialize_attributes is included from ActiveRecord::AttributeMethods::Serialization and since 3.2.5 accepts
    an options hash which can control whether or not the attributes are initialized serialized or unserialized.
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +2 −1  lib/composite_primary_keys/base.rb
View
3  lib/composite_primary_keys/base.rb
@@ -59,6 +59,7 @@ def composite?
def initialize_dup(other)
cloned_attributes = other.clone_attributes(:read_attribute_before_type_cast)
+ self.class.initialize_attributes(cloned_attributes, :serialized => false)
# CPK
# cloned_attributes.delete(self.class.primary_key)
Array(self.class.primary_key).each {|key| cloned_attributes.delete(key.to_s)}
@@ -148,7 +149,7 @@ def can_change_primary_key_values?
def to_key
ids.to_a if !ids.compact.empty? # XXX Maybe use primary_keys with send instead of ids
end
-
+
def to_param
persisted? ? to_key.join(CompositePrimaryKeys::ID_SEP) : nil
end
Something went wrong with that request. Please try again.