Hi,

I came across the strangest issue I have no idea how it happened. In
my development environment, I created a new migration and model that
uses a couple of decimal column types (among others). Everything
works great with sqlite and the development environment, business as
usual. However, I deployed to production and for some completely
unknown reason, this particular table (only this one) shows up with
"integer" column types.

To clarify, when I investigate the MYSQL db in production, MYSQL shows
that the columns are decimal types. However, when type in the model
class name into the production console, it shows the column types as
integer. This is a problem for me because it's holding prices, so I'm
losing my cents (no pun intended).

How does rails determine the column types? The migration shows
decimal column types, by the way.

Thanks to anyone that has any insight.
Nick

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Precisio at Jan 12, 2012 at 9:37 pm
    Ignore my plea. It turns out I have the wrong precision on the table
    columns. Even though they were indeed decimals, rails saw the 0 scale
    on the table column and thought that they were integers. Dang, that's
    a gotcha!

    On Jan 12, 1:25 pm, Precisio wrote:
    Hi,

    I came across the strangest issue I have no idea how it happened.  In
    my development environment, I created a new migration and model that
    uses a couple of decimal column types (among others).  Everything
    works great with sqlite and the development environment, business as
    usual.  However, I deployed to production and for some completely
    unknown reason, this particular table (only this one) shows up with
    "integer" column types.

    To clarify, when I investigate the MYSQL db in production, MYSQL shows
    that the columns are decimal types.  However, when type in the model
    class name into the production console, it shows the column types as
    integer.  This is a problem for me because it's holding prices, so I'm
    losing my cents (no pun intended).

    How does rails determine the column types?  The migration shows
    decimal column types, by the way.

    Thanks to anyone that has any insight.
    Nick
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Robert Walker at Jan 12, 2012 at 9:46 pm

    Precisio wrote in post #1040594:
    Ignore my plea. It turns out I have the wrong precision on the table
    columns. Even though they were indeed decimals, rails saw the 0 scale
    on the table column and thought that they were integers. Dang, that's
    a gotcha!
    This is why I always specify precision and scale in my migrations:

    t.decimal :price, :precision => 10, :scale => 2

    This removes any confusion between the migration and database schema.

    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJan 12, '12 at 9:25p
activeJan 12, '12 at 9:46p
posts3
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Precisio: 2 posts Robert Walker: 1 post

People

Translate

site design / logo © 2021 Grokbase