How to generate a model without creating a migration

For example, you have already created a migration for ProductCategory

Then you type:

$ rails generate model ProductCategory

you will see something like:

  invoke  active_record
    conflict    db/migrate/20160915185620_create_product_categories.rb
Another migration is already named create_product_categories: /Projects/test/db/migrate/20160915184653_create_product_categories.rb. Use --force to replace this migration file.  

The way to do it's to use a flag to skip migrations:

--skip-migration

$ rails generate model ProductCategory --skip-migration
      invoke  active_record
      create    app/models/product_category.rb
      invoke    rspec
      create      spec/models/product_category_spec.rb

There you go.

Victor Velazquez

Coder, Musician, Startups, Passionate Dancer & Life Lover. Software Engineer at MagmaLabs, Co-founder of Web Dev Talks, Co-founder of Voltaire, Co-founder of Paqkit, Ex-co-founder of Zaznova.

Subscribe to The zazvick's blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!