# How updating the views when changing the DB?

**URL:** <https://www.ruby-forum.com/t/how-updating-the-views-when-changing-the-db/143018>\
**Category:** Rails\
**Created:** [July 14, 2008, 3:57pm UTC](https://www.ruby-forum.com/t/how-updating-the-views-when-changing-the-db/143018 "2008-07-14T15:57:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![monsterag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@monsterag](https://www.ruby-forum.com/u/monsterag)\
**Post date:** [July 14, 2008, 3:57pm UTC](https://www.ruby-forum.com/t/how-updating-the-views-when-changing-the-db/143018/1 "2008-07-14T15:57:36Z")

</div>

Hello,  
i am new to Ruby.  
question:  
i used scaffold to create a Database migration with lets say 2 fields:  
name:string surname:string

The scaffolding and migrationprocess has done the DB and the view edit  
delete action.

I want to add a new database field. I can do this in the migrationfile  
and the schema file and do the db migration again but the scaffolding  
part is not done again.  
Is there a way to do this automatically? Otherways i allways have to  
delete the Database and do all the scaffolding again and my changes made  
to the views are lost.

Any idea?  
tia

---

<div class="post-metadata">

**Author:** ![monsterag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@monsterag](https://www.ruby-forum.com/u/monsterag)\
**Post date:** [July 14, 2008, 5:29pm UTC](https://www.ruby-forum.com/t/how-updating-the-views-when-changing-the-db/143018/2 "2008-07-14T17:29:37Z")

</div>

You’ll want to create a new migration:

ruby script/generate migration \<migration\_name\>

then edit the migration to add the field (descriptive migration naming  
will help you later)

run the migration and add that field to the index/edit/new views… no  
need to redo the database in total.

A Rails app is built of many migrations, which most see as a normal part  
of refactoring as new features or capabilities are added over time.

---

<div class="post-metadata">

**Author:** ![monsterag](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@monsterag](https://www.ruby-forum.com/u/monsterag)\
**Post date:** [July 14, 2008, 5:49pm UTC](https://www.ruby-forum.com/t/how-updating-the-views-when-changing-the-db/143018/3 "2008-07-14T17:49:05Z")

</div>

Thanks,  
so i have to add the new fields by hand to the view manually. The  
database thing is running fine. My question was about the manual  
changing the view/index/edit-files.  
So there is no way to do this automatically?
