hunterp
hunterp

Reputation: 15986

How to regenerate scaffold in rails?

I generated a scaffold with a flat model named Brick, then I created 2 new models named concrete and mortar and added has_one relationship to Brick.

Now I want to regenerate the scaffold, but I get this error:

Another migration is already named create_brick_items: Construction/db/migrate/20121210193959_create_brick_items.rb

Upvotes: 0

Views: 1008

Answers (2)

Dominik
Dominik

Reputation: 111

To your question how to regenerate scaffold. You need to:

  1. If you already run migrations you have to do rollback rake db:rollback or if you dint need your data you can drop database and then create new database
  2. Then you can destroy generated scaffold like rails destroy scaffold Brick
  3. Finally you can generate your new scaffold rails generate scaffold Bricks name:string mortar:references

Upvotes: 1

Antarr Byrd
Antarr Byrd

Reputation: 26169

rails generate migration AddMortarToBrick mortar:references or what ever brick has one of

Upvotes: 1

Related Questions