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

Conversation

Projects
None yet
5 participants
@ka8725
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@avsej

avsej commented Oct 25, 2013

👍

rafaelfranca added a commit that referenced this pull request Oct 25, 2013

Merge pull request #12642 from ka8725/fix_usage_for_model_generators
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

Merge pull request #12642 from ka8725/fix_usage_for_model_generators
Improve usage example for model generator decimal field
@jonathanjd

This comment has been minimized.

Show comment
Hide comment
@jonathanjd

jonathanjd commented Feb 8, 2016

Nice

@lin0x

This comment has been minimized.

Show comment
Hide comment
@lin0x

lin0x Apr 22, 2016

Thank you ka8725 👍

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