We have to compute with prices that are decimal. In database is stored something like 123,45 but after calling
we received 123 instead of 123.45 (#<BigDecimal:4b5850c,'0.12345e3',8(12)>)
I traced ActiveRecord and found that method find (its internal implementation) uses method instantiate and it calls object.instance_variable_set("@attributes", record) and this method is just stub for C runtime libraries.
So I created solution - override method instance_variable_set in model class Amount like this:
def instance_variable_set symbol, obj
if symbol == "@attributes"
input = obj["value"]
unless input.nil? or input.index(",").nil?
input[input.index(",")] = "."
@value = BigDecimal.new(input)
Any better solution?