0

I use Ruby sinatra with datamapper. In my model I have a decimal property

property :sim_update_interval, Decimal, :precision=>10, :scale=>2 , :default=>0.9

The problem is: Everytime I creates a new instance of the model, the default value of :sim_update_interval is never 0.9, but 1.0

puts instance.sim_update_interval 
#=> 0.1E1

I tried to change the default value to 0.2, the output became 0.0 It seems that datamapper always round the default value to an integer. I am so confused

GingerJim
  • 3,737
  • 6
  • 26
  • 36

1 Answers1

2

Turns out that rake db:migrate do not modify existing columns when there is data(rows) in the table. I wiped the table and do rake db:migrate, everything is ok now.

GingerJim
  • 3,737
  • 6
  • 26
  • 36