Instead of directly accessing @attributes, you should use read_attributeand write_attribute:
def brand
b = read_attribute(:brand)
b && b.transform_in_some_way
end
def brand=(b)
b && b.transform_in_some_way
write_attribute(:brand, b)
end
source
share