Search code examples
ruby-on-railsscaffolding

scaffold does not update view


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!


Solution

  • 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.