0

I was noticed that BigDecimal attribute in my db row changing every page reloading.

sum: #<BigDecimal:4add7d0,'0.9E0',9(36)>
ctrl+r
sum: #<BigDecimal:639f200,'0.9E0',9(36)>
ctrl+r
sum: #<BigDecimal:594ceb0,'0.9E0',9(36)>

Is it ok?

anndrew78
  • 196
  • 1
  • 20

1 Answers1

3

It looks to me like the Object ID is changing, but not the value; all of the results you list use the format #<BigDecimal:xxxxxxx,'0.9E0',9(36)>

Each time you reload the page, Rails is creating a new BigDecimal object instance, but with the same data in it. Here's a similar example, using the irb console:

irb(main):004:0> require 'bigdecimal'
=> true
irb(main):005:0> BigDecimal(9)
=> #<BigDecimal:2aadb50,'0.9E1',9(36)>
irb(main):006:0> BigDecimal(9)
=> #<BigDecimal:2764ab8,'0.9E1',9(36)>
irb(main):007:0> BigDecimal(9)
=> #<BigDecimal:25c3638,'0.9E1',9(36)>
irb(main):008:0>
GoBusto
  • 4,632
  • 6
  • 28
  • 45