From Ruby on Rails: best method of handling currency / money, how do you generate a scaffold for the folowing:
add_column :items, :price, :decimal, :precision => 8, :scale => 2
Such as:
rails generate scaffold LineItem name:string \
price:decimal {:precision => 8, :scale => 2}
Also, what is the correct term for "extra description" for the decimal type?
Working in Rails 3.07, Ruby 1.92
In Rails 3.1 and below, the syntax is
rails generate scaffold LineItem name:string price:decimal
and then manually add the decimal properties to the migration file
t.decimal :price, :precision => 8, :scale => 2
In Rails 3.2, one can specify the decimal properties
rails generate scaffold LineItem name price:decimal{8,2}
NOTE: If you are running ZSH, the syntax requires a hyphen instead of a comma.
rails generate scaffold LineItem name price:decimal{8-2}
ANOTHER NOTE: If you are using bash under Mac OS X 10.9 try a dot instead of the comma
rails generate scaffold LineItem name price:decimal{8.2}