Browse files

Return nil from read_attribute if _foo is defined, but @attributes ha…

…s no 'foo' key. Fixes breakage in test_find_only_some_columns on Ruby 1.9 which was introduced in a3639be.
  • Loading branch information...
1 parent 36691ac commit 912e5ff7903f6e44f3dcc7029b715a1670fc3040 @jonleighton jonleighton committed Apr 15, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/attribute_methods/read.rb
View
2 activerecord/lib/active_record/attribute_methods/read.rb
@@ -78,7 +78,7 @@ def define_read_method(symbol, attr_name, column)
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
def read_attribute(attr_name)
if respond_to? "_#{attr_name}"
- send "_#{attr_name}"
+ send "_#{attr_name}" if @attributes.has_key?(attr_name.to_s)
else
_read_attribute attr_name
end

0 comments on commit 912e5ff

Please sign in to comment.