Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve usage example for model generator decimal field #12642

Merged
merged 1 commit into from
Oct 25, 2013
Merged

Improve usage example for model generator decimal field #12642

merged 1 commit into from
Oct 25, 2013

Conversation

ka8725
Copy link
Contributor

@ka8725 ka8725 commented Oct 25, 2013

We should wrap parameters to quotes when pass parameters with curly braces to decimal generator because the shell (tested in bash and zsh) transforms them to several params. Example:

$ echo p{1,2}
p1 p2

So actual example (rails generate model product price:decimal{10,2}) generates migration like this:

class CreateProducts < ActiveRecord::Migration
  def change
    create_table :products do |t|
      t.decimal10 :price
      t.decimal2 :price

      t.timestamps
    end
  end
end

Fixed version of the command (rails generate model product 'price:decimal{10,2}') generates correct migration:

class CreateProducts < ActiveRecord::Migration
  def change
    create_table :products do |t|
      t.decimal :price, precision: 10, scale: 2

      t.timestamps
    end
  end
end

@avsej
Copy link

avsej commented Oct 25, 2013

👍

rafaelfranca added a commit that referenced this pull request Oct 25, 2013
Improve usage example for model generator decimal field
@rafaelfranca rafaelfranca merged commit 3c3ffac into rails:master Oct 25, 2013
rafaelfranca added a commit that referenced this pull request Oct 25, 2013
Improve usage example for model generator decimal field
@jonathanjd
Copy link

Nice

@lin0x
Copy link

lin0x commented Apr 22, 2016

Thank you ka8725 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants