Permalink
Browse files

Properly typecast id attribute when using custom primary key

  • Loading branch information...
1 parent 648248b commit 77a0fc1c7a7681bae6d1956cadcb8b3ef9428896 @carlosantoniodasilva carlosantoniodasilva committed Mar 30, 2012
Showing with 4 additions and 1 deletion.
  1. +4 −1 activerecord/lib/active_record/attribute_methods/read.rb
@@ -67,7 +67,10 @@ def read_attribute(attr_name)
@attributes_cache.fetch(attr_name.to_s) { |name|
column = @columns_hash.fetch(name) {
return @attributes.fetch(name) {
- @attributes[self.class.primary_key] if name == 'id'
+ if name == 'id'
+ primary_key = self.class.primary_key
+ @columns_hash[primary_key].type_cast(@attributes[primary_key])
+ end
}
}

0 comments on commit 77a0fc1

Please sign in to comment.