Search code examples
ruby-on-railsruby

Where do I put the -p flag when running a "rails generate" in "pretend" mode?


The Rails help message says:

General options:
  -h, [--help]     # Print generator's options and usage
  -p, [--pretend]  # Run but do not make any changes
  -f, [--force]    # Overwrite files that already exist
  -s, [--skip]     # Skip files that already exist
  -q, [--quiet]    # Suppress status output

I'm specifically interested in -p to see what files would be generated. However, the following commands don't work:

rails generate -p migration CreateFoo foo:string
rails generate migration -p CreateFoo foo:string

How do I run a "pretend" generate command in Rails?


Solution

  • The -p flag goes at the end of the command, eg:

    rails generate migration CreateFoo foo:string -p