diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-03-29 21:23:34 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-03-29 22:59:30 -0300 |
commit | 77a0fc1c7a7681bae6d1956cadcb8b3ef9428896 (patch) | |
tree | 64e3d971a9b1a2b94b88ad00dac758051ae777cd /activerecord | |
parent | 648248bbb13aa5259b1e64d9a8376cdbe6717e37 (diff) | |
download | rails-77a0fc1c7a7681bae6d1956cadcb8b3ef9428896.tar.gz rails-77a0fc1c7a7681bae6d1956cadcb8b3ef9428896.tar.bz2 rails-77a0fc1c7a7681bae6d1956cadcb8b3ef9428896.zip |
Properly typecast id attribute when using custom primary key
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/read.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb index faed703167..d108de385f 100644 --- a/activerecord/lib/active_record/attribute_methods/read.rb +++ b/activerecord/lib/active_record/attribute_methods/read.rb @@ -67,7 +67,10 @@ module ActiveRecord @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 } } |