# Scaffold question

**URL:** <https://www.ruby-forum.com/t/scaffold-question/121586>\
**Category:** Rails\
**Created:** [November 29, 2007, 3:33am UTC](https://www.ruby-forum.com/t/scaffold-question/121586 "2007-11-29T03:33:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![emarthinsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/91b2a8/32.png) [@emarthinsen](https://www.ruby-forum.com/u/emarthinsen)\
**Post date:** [November 29, 2007, 3:33am UTC](https://www.ruby-forum.com/t/scaffold-question/121586/1 "2007-11-29T03:33:21Z")

</div>

Hello-

I have a class called Product that has a relationship with another  
class called Category. The Product “belongs\_to :category” and the  
Category “has\_many :products”. In my admin controller for Products,  
which I’m using scaffold to generate, I’d like to have a drop-down  
list of the categories show up. Is there an easy way to do this, or  
should I generate the scaffold code and edit it by hand? Thanks in  
advance.

-Eric

---

<div class="post-metadata">

**Author:** ![emarthinsen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/91b2a8/32.png) [@emarthinsen](https://www.ruby-forum.com/u/emarthinsen)\
**Post date:** [November 29, 2007, 3:39am UTC](https://www.ruby-forum.com/t/scaffold-question/121586/2 "2007-11-29T03:39:48Z")

</div>

On Nov 28, 2007 8:32 PM, emarthinsen [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have a class called Product that has a relationship with another  
> class called Category. The Product “belongs\_to :category” and the  
> Category “has\_many :products”. In my admin controller for Products,  
> which I’m using scaffold to generate, I’d like to have a drop-down  
> list of the categories show up. Is there an easy way to do this, or  
> should I generate the scaffold code and edit it by hand? Thanks in  
> advance.

Here’s how to build a drop down menu:

[http://api.rubyonrails.com/classes/ActionView/Helpers/FormOptionsHelper.html#M000512](http://api.rubyonrails.com/classes/ActionView/Helpers/FormOptionsHelper.html#M000512)

If you scroll that page back up a little you’ll see several options  
for making options to go with your drop down menu.

Scaffolds are neato and all but at some point they usually get tossed  
out for custom code or heavily customized themselves.

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)
