1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

read_attribute_before_type_cast should accept symbol

This commit is contained in:
Neeraj Singh 2013-05-11 03:08:08 -04:00
parent e4ec944eac
commit 3e0c06d8ab
3 changed files with 7 additions and 1 deletions

View file

@ -1,3 +1,7 @@
* Method read_attribute_before_type_cast should accept input as symbol.
*Neeraj Singh*
* Confirm a record has not already been destroyed before decrementing counter cache.
*Ben Tucker*

View file

@ -41,8 +41,9 @@ module ActiveRecord
# task.read_attribute_before_type_cast('id') # => '1'
# task.read_attribute('completed_on') # => Sun, 21 Oct 2012
# task.read_attribute_before_type_cast('completed_on') # => "2012-10-21"
# task.read_attribute_before_type_cast(:completed_on) # => "2012-10-21"
def read_attribute_before_type_cast(attr_name)
@attributes[attr_name]
@attributes[attr_name.to_s]
end
# Returns a hash of attributes before typecasting and deserialization.

View file

@ -130,6 +130,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
assert_equal '10', keyboard.id_before_type_cast
assert_equal nil, keyboard.read_attribute_before_type_cast('id')
assert_equal '10', keyboard.read_attribute_before_type_cast('key_number')
assert_equal '10', keyboard.read_attribute_before_type_cast(:key_number)
end
# Syck calls respond_to? before actually calling initialize