Scaffold question

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

On Nov 28, 2007 8:32 PM, emarthinsen [email protected] 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

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/