Products and categories for e-commerce shop

Hi I have implemented products and categories in the back-end of my
e-commerce site. Basically I modelled it like this a product belongs_to
a category and a category has many products. So an admin can select a
category for a product and it saves correctly. What I would now like to
do is show a category with all the products associated with it for
example I have a T-shirt category so to show all the T-shirts in the
shop. What would I need to change in my application for this to work?

On 25 March 2012 18:48, Shaban K. [email protected] wrote:

Hi I have implemented products and categories in the back-end of my
e-commerce site. Basically I modelled it like this a product belongs_to
a category and a category has many products. So an admin can select a
category for a product and it saves correctly. What I would now like to
do is show a category with all the products associated with it for
example I have a T-shirt category so to show all the T-shirts in the
shop. What would I need to change in my application for this to work?

You don’t need to post your whole app for such a simple question. If
you have a category in @category for example, then the products for
that category are just @category.products so you can just loop through
them displaying what you want.

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs