Specifying a decimal field precision/scale with scaffold requires 2 steps?

Hi,

It appears to me that the command:
ruby script/generate scaffold whatever money_field:decimal(10,2)
will not generate a valid migration.

Therefore it appears to me only two ways to achieve the desired result
is:

1.1 Omit the the precision/scale on the scaffold command
1.2 Edit the migration file by following the “do |t| … end” with
the command:

change_column :whatever :money_field, :amount, :decimal,
:precision
=> 10, :scale => 2
I think this approach worked for me

2.1 Omit the money_field in it’s entirety
2.2 Create a second migration file an add the command:

add_column :whatever :money_field, :amount, :decimal, :precision
=> 10, :scale => 2
I’m guessing this will work as well

BTW, I’m running Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox
3.6.2, Firebug 1.5.3,
MySQL 5.0.37-community-nt, Mongrel, Apache HTTP Server 2.2.15

What do you think?

Best wishes,
Richard

On Sat, Apr 3, 2010 at 4:02 PM, RichardOnRails <
[email protected]> wrote:

Hi,

It appears to me that the command:
ruby script/generate scaffold whatever money_field:decimal(10,2)
will not generate a valid migration.

Yes, the syntax is invalid and the correct syntax should be:

ruby script/generate scaffold whatever money_field:decimal

Next, you’ll simply have to edit the migration file to add the scale
option.

Good luck,

-Conrad

Thanks, Conrad.

I thought since we’re on Rails 2 there’d be a better way. But I guess
that scaffold is going to be deprecated soon, so core members don’t
want to do any more work on it. Too bad, because it’s a way neat to
get a concept-demo fast and amaze prospective clients.

Best wishes,
Richard