# Scaffold and foreign keys

**URL:** <https://www.ruby-forum.com/t/scaffold-and-foreign-keys/136512>\
**Category:** Rails\
**Created:** [May 27, 2007, 4:14pm UTC](https://www.ruby-forum.com/t/scaffold-and-foreign-keys/136512 "2007-05-27T16:14:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phirefly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e9a140/32.png) [@phirefly](https://www.ruby-forum.com/u/phirefly)\
**Post date:** [May 27, 2007, 4:14pm UTC](https://www.ruby-forum.com/t/scaffold-and-foreign-keys/136512/1 "2007-05-27T16:14:22Z")

</div>

Hello,  
I create a migration to add a foreign key ‘page\_id’ to a table  
‘main\_sections’. After running the migration and adding the column,  
the scaffol that I have on the main\_setions table does not add the  
foreign key into the CRUD.

Any ideas why this is the case?

Thanks.

---

<div class="post-metadata">

**Author:** ![phirefly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e9a140/32.png) [@phirefly](https://www.ruby-forum.com/u/phirefly)\
**Post date:** [May 27, 2007, 4:19pm UTC](https://www.ruby-forum.com/t/scaffold-and-foreign-keys/136512/2 "2007-05-27T16:19:23Z")

</div>

I think you have to re-run scaffolding to see anything new. It’s a  
generator, and creates a static snapshot of the current structure,  
not a run-time-automatic-introspecting view which would update each  
time something changed about the structure.

Walter

---

<div class="post-metadata">

**Author:** ![phirefly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e9a140/32.png) [@phirefly](https://www.ruby-forum.com/u/phirefly)\
**Post date:** [May 28, 2007, 4:58pm UTC](https://www.ruby-forum.com/t/scaffold-and-foreign-keys/136512/3 "2007-05-28T16:58:35Z")

</div>

Thanks, I’ll try that…
