views:

39

answers:

2

Hi there

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!

+3  A: 

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?

Eimantas
A: 

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.

Steve Weet
Thanks a lot for your answers! I thought I have seen that the views were updated automatically in a tutorial, but I might be wrong.Thanks Steven for the nifty_scaffold tip, I think I'm gonna give it a try.
doemsche