Ruby on Rails decimals? -


i have migration in database has t.decimal type called decnum. have tried doing things mdl.decnum = 3.3, , mdl.save, saves decnum 3, instead of decimal defined. doing mdl.decnum.class returns fixnum, showing not decimal type. i've tried mdl.decnum = bigdecimal.new("3.3"), doesn't work expected. finally, tried mdl.decnum = 3.to_d, didn't work either. how initialize model, or set variable after decimal?

your migrationn should have this:

t.decimal :decnum, :precision => 9, :scale => 2, :default => '0.0' 

scale number of charachers after comma


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -