jeudi 3 mars 2016

Create Chained seed on Rails

i have a db with Gender, Category and Subcategories chained.

so to not lost time i would like to know how to chain the seed

for Exemple:

  1. Gender Masculine
  2. Categoy Clothes
  3. Subcategory T-shirts

and so on.

until now i created on this way the relation between Gender and Categories:

g = Gender.create(:gender => 'Masuline')
g.categories.create(:name => "Clothes")

and to chain the subcategory is just to create below and they chain?

thank's

Aucun commentaire:

Enregistrer un commentaire