2
votes

I have a question to the following procedure:

  • script/generate scaffold product title:string description:text
  • db:migrate
  • then I generate a migration which adds a column description to the

    table products and migrate the db again.

My question is: why is the field description not added to the project-views? Is that normal rails scaffold behaviour? I think I saw in a video tutorial that the scaffold updates as well the views, which would be very convenient. Thanks in advance for any help!

2

2 Answers

3
votes

This is normal since scaffold does not "monitor" changes to the table or to any other scaffold-related resource (controller, model, views, tests, etc.).

then I generate a migration which adds a column description to the table products

You have description column already when generating the scaffold. Why do you need another migration for this?

2
votes

This is normal behaviour for scaffolding, however there are alternatives.

If you were to look at Ryan Bates nifty_scaffold generator then this would allow you to re-run the scaffold generation. Assuming that you hadn't changed the generated code.

These generators can regenerate the views/spec/tests based upon the current state of the database model.

Be aware that if you have already customised the views yourself then they could be overwritten.