Skip to content


Subversion checkout URL

You can clone with
Download ZIP


scaffold/model/migration generators not correctly generate decimal with precision scale shorthand #4602

joneslee85 opened this Issue · 5 comments

6 participants


rails g scaffold Post price:decimal{7,2} generates:

    t.decimal7 :price
    t.decimal2 :price 

which is so wrong.

@josevalim josevalim closed this in ede01ce
@iHiD iHiD referenced this issue from a commit in iHiD/rails
@josevalim josevalim Support decimal{1,2} and decimal{1-2} and decimal{1.2} so it works fi…
…ne with bash, zsh, etc, closes #4602



The {1.2} and {1-2} works however the {1,2} still produce wrong migration. Please re-open the ticket.


I'm on 3.2.1, ZSH and {1,2} doesn't work for me either. Switching to {1-2} did work though.


Hey @joneslee85 and @cgunther the {1.2} and {1-2} as added to users with shell that expand the {1,2} syntax. So if {1,2} doesn't work to you please use {1.2} or {1-2} syntax.


Just to clarify the issue for the benefit of anyone who googles their way here:

The Rails generator wasn't broken. The documentation just failed to take into account that curly braces are metacharacters in Bash (as well as other shells) and need to be escaped.


$ echo rails g scaffold Post price:decimal{7,2}

and you'll see that it expands to

rails g scaffold Post price:decimal7 price:decimal2

The generator isn't smart enough to detect that you defined two columns named price. Nor does it catch that there are no such datatypes as decimal7 or decimal2.

The proper thing to do is to escape the braces with either quotes or backslashes.

Alternatively, you can use an alternate form that Jose Valim added last month.
Instead of a comma, use a dot or dash. Bash does not expand those forms:

$ echo price:decimal{7.2} price:decimal{7-2}
price:decimal{7.2} price:decimal{7-2}

{1,2} doesn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.