# How to describe a decimal field in Rails scaffolding

**URL:** <https://www.ruby-forum.com/t/how-to-describe-a-decimal-field-in-rails-scaffolding/183800>\
**Category:** Rails\
**Created:** [February 20, 2010, 1:28pm UTC](https://www.ruby-forum.com/t/how-to-describe-a-decimal-field-in-rails-scaffolding/183800 "2010-02-20T13:28:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nfv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ac91a4/32.png) [@nfv](https://www.ruby-forum.com/u/nfv)\
**Post date:** [February 20, 2010, 1:28pm UTC](https://www.ruby-forum.com/t/how-to-describe-a-decimal-field-in-rails-scaffolding/183800/1 "2010-02-20T13:28:39Z")

</div>

Hi,

Can anyone explain how to use decimals in Rails scaffolding ?

When I enter the scaffold command :

ruby script/generate scaffold payment amount:decimal, :precision =\>  
10, :scale =\> 2 event:string datum:date

nothing happens. No error message, no generating of files, nothing.

When I enter the scaffold command :

ruby script/generate scaffold payment amount:decimal event:string  
datum:date

and then open the generated migrate file and add precision and  
scale :

t.decimal :amount, :precision =\> 10, :scale =\> 2

then an amount column of type decimal(10,2) is created in my MySQL db.

Is it not possible to describe the precision and scale in the scaffold  
command ?

Thanks

---

<div class="post-metadata">

**Author:** ![nfv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ac91a4/32.png) [@nfv](https://www.ruby-forum.com/u/nfv)\
**Post date:** [February 20, 2010, 2:12pm UTC](https://www.ruby-forum.com/t/how-to-describe-a-decimal-field-in-rails-scaffolding/183800/2 "2010-02-20T14:12:39Z")

</div>

nfv wrote:

> Hi,
> 
> Can anyone explain how to use decimals in Rails scaffolding ?
> 
> When I enter the scaffold command :
> 
> ruby script/generate scaffold payment amount:decimal, :precision =\>  
> 10, :scale =\> 2 event:string datum:date
> 
> nothing happens. No error message, no generating of files, nothing.
> 
> When I enter the scaffold command :
> 
> ruby script/generate scaffold payment amount:decimal event:string  
> datum:date
> 
> and then open the generated migrate file and add precision and  
> scale :
> 
> t.decimal :amount, :precision =\> 10, :scale =\> 2
> 
> then an amount column of type decimal(10,2) is created in my MySQL db.
> 
> Is it not possible to describe the precision and scale in the scaffold  
> command ?
> 
> Thanks

I tried to my best. Since there are no option to specify it, the only  
way to do it by manually editing in the migration file.  
Revert back me if u find any more solution.

Thanks

---

<div class="post-metadata">

**Author:** ![nfv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/ac91a4/32.png) [@nfv](https://www.ruby-forum.com/u/nfv)\
**Post date:** [February 20, 2010, 6:09pm UTC](https://www.ruby-forum.com/t/how-to-describe-a-decimal-field-in-rails-scaffolding/183800/3 "2010-02-20T18:09:35Z")

</div>

I had tried to my best. Since there were no option to specify the  
additional parameters. It has to be manually specified in the  
migration file.  
Revert back me if u find any solution to it.
