vendredi 25 novembre 2016

rails has many relation through other table

I have 4 tables, All of them are connected to each other.

restaurant -> has_many -> menus
menu -> has_many -> categories
category -> has_many -> menu items

I tried to access categories from restaurant through menu table and it is not working

I want to access categories and menu items from restaurant table, is it possible

for example

Restaurant.find(1).categories
Restaurant.find(1).menu_items

Aucun commentaire:

Enregistrer un commentaire