Topic: Adding Categories to my products

I have created my product model now i wish to be able to categorize products. My thinking is a category model with name and id, then add category id to product model. But how do i add a select menu to my product form when creating or updating that includes the categories i have in my database.
So far I have

belongs_to category

has_many products

I've created my categories Now I want to link them to a product and also show each category seperatley with their products

Last edited by dannyconnolly (2011-12-23 13:19:05)

Re: Adding Categories to my products

<%= :category , Category.find(:all).collect {|c| [c.description,]} %>

assuming the attribute that describes the category is called 'description'

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Adding Categories to my products

Hi brad Thanks for that, two questions though, when I create a new product the category id isn't being added to the products table how do I achieve this?, and also how do I get the category title to show for the product instead of the id?