Displaying data from multiple models in a single view

I’m new to Ruby on Rails and I’m working on a simple app that manages
serial numbers/product keys for software.

I have three models and database tables setup:


I’ve setup a view that shows each category on its own page. On a
category page, I’d like to have listed all of the products that belong
to that category along with all of the serial numbers that belong to
each product.

While I’m able to properly list all the products, I have no clue how to
display a list of serials for each product.

I’ve added has_many() and belongs_to() in my models and setup foreign
keys in my database tables.

Any help would be appreciated. Thanks.

Here are some links that helped me…

page 5 and the code download help explain

page 5 gets relational

Some other good tutorials are listed here…

The book “Agile Web D. with Rails” is worth investing in also.


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