Forum: Ruby on Rails Floats being stored in database as integer?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
matt (Guest)
on 2006-04-02 22:30
Hi all - having a problem that's driving me insane. I was working on a
project that required reading in Access MDB files, then writing them to
a mySQL DB. I got it working, but the DB had a bunch of worthless data
from my previous testing - so I dropped the table to start fresh. Once I
dropped it, the float values from the Access read are being written to
the DB as integers. If I print the values I have assigned just before
the write, they come up correctly as floats. However, once in the DB -
they are only 8 bytes. I am baffled... the DB schema lists the fields as
floats. Code below.

dbh.select_all('select * from steel') do |row|
        @record = Report.new
        Report.content_columns.each do |col|
           @record[col.name] = row.shift
         end
        @record.save
      end

Any advice appreciated.
matt (Guest)
on 2006-04-02 22:53
An update - problem solved I think? I took a look at the development.log
file and saw the SQL statements going in w/ the float #'s correct. While
a 'float' type was big enough, it wasn't working. I changed it to double
and it's now fine. I also didn't know schema.rb supported the double
type, but it now appears to.
This topic is locked and can not be replied to.