samedi 16 avril 2016

Create Chained Seeds on Rails 3.2

I have a issue here, i'm chaining a Gender + Category + Subcategory seeds of products.

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


g = Gender.create(:gender => 'Woman')
g.categories.create(:name => "Accessories")


m = Category.find_by_name("Clothes")
m.subcategories.create(:name => "T-shirts" )


f = Category.find_by_name("Accessories")
f.subcategories.create(:name => "Rings" )

The issue is: Every time that i create the seeds the Woman subcategories is created on Man Subcategories Table. someone can helpme on this?

thank's

Aucun commentaire:

Enregistrer un commentaire