There are times when we might need the value of an attribute before rails type-casting it.
Suppose obj is the object and attrib is the attribute whose value we need before ActiveRecord type-casted it, there's a method we can use to get the value of that attribute it was before being type-casted, which works as follows:
obj.attrib_before_type_cast
will give you the value prior to being type-casted. The _before_type_cast does all the magic here.
Suppose obj is the object and attrib is the attribute whose value we need before ActiveRecord type-casted it, there's a method we can use to get the value of that attribute it was before being type-casted, which works as follows:
obj.attrib_before_type_cast
will give you the value prior to being type-casted. The _before_type_cast does all the magic here.
No comments:
Post a Comment