Specify precision and scale attributes for decimal number with scaffold/model/migration generators in Rails 3.2.0

By using the short hand  :decimal{precision, scale}, rails generator lets you generate number migration with decimal and scale. You could use {precision, scale} or {precison-scale} or {precision.scale} shorhand:

rails g scaffold Product title:string price:decimal{8,2}

the above would generate a migration of:

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

NOTE: sadly, this feature is so broken as of the release of 3.2.0 and is addressed in the bug #4602.

Advertisements

About Jones Lee

Nothing much about me..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: