Skip to content

Commit

Permalink
Properly typecast id attribute when using custom primary key
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosantoniodasilva committed Mar 30, 2012
1 parent 648248b commit 77a0fc1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion activerecord/lib/active_record/attribute_methods/read.rb
Expand Up @@ -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
}
}

Expand Down

0 comments on commit 77a0fc1

Please sign in to comment.