Problem with decimal data type

I ran a migration with the following:

create_table :userlevels do |t|
# t.column :name, :string
t.column :usertype, :string, :limit => 15
t.column :userlevel, :string, :limit => 15
t.column :price, :decimal, :precision => 7, :scale => 2
end

The problem is the decimal column. rake ignored the precision and scale
parameters and defined it as decimal(10,0). What’s the magic words to
actually get rake to create a decimal column with decimal places? I’m
sure it’s obvious, but I don’t see it.

Thanks in advance
—Michael

The column type :decimal didn’t work in my installation, so I worked
around it with a plain MySQL statement in the migration script instead
of your t.column statement:
t.column :price, :float
execute “alter table products modify column price decimal(8,2)”

Michael S. wrote:

I ran a migration with the following:

create_table :userlevels do |t|
# t.column :name, :string
t.column :usertype, :string, :limit => 15
t.column :userlevel, :string, :limit => 15
t.column :price, :decimal, :precision => 7, :scale => 2
end

The problem is the decimal column. rake ignored the precision and scale
parameters and defined it as decimal(10,0). What’s the magic words to
actually get rake to create a decimal column with decimal places? I’m
sure it’s obvious, but I don’t see it.

Thanks in advance
—Michael

Thanks man, that did the trick !

Simple.

Groetjes

On 10/6/06, Michael S. [email protected]
wrote:

The problem is the decimal column. rake ignored the precision and scale
parameters and defined it as decimal(10,0). What’s the magic words to
actually get rake to create a decimal column with decimal places? I’m
sure it’s obvious, but I don’t see it.

You need to be running edge rails. Decimal support isn’t included in
the stable release.

Isak

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs