[RUBY] How to create hierarchical category data using ancestry

Introduction

I am cloning a flea market app for the final assignment of a certain programming school (78th term). I will describe the following contents that I worked on in the implementation of the "category selection function" required for the product listing function.

--Creating a data table using ancestry

What you can see in this article

How to create a category table by introducing gem ancestry.

Goals you want to achieve with this feature

Create a hierarchical data table, such as "Ladies ▶ ︎Tops ▶ ︎T-shirt". Ultimately, this data will be used to select a category on the listing screen as shown below, or to display a category when selecting a product on the top screen. qiita qiita

Development environment

Rough flow

  1. Install gem ancestry
  2. Create a categories table (create a container for data)
  3. Write the data to be registered in the seed.rb file (create the data itself)
  4. Reflect the data with rails db: seed

As a premise, it is assumed that the items table that manages products has already been created.

Implementation procedure

1. Introduction of gem ancestry

gem ancestry

2. Creating a category table

Create a category table.

rails g model category

The association in the model looks like this. The important thing is to write has_ancestry in the ** category model **.

category.rb


class Category < ApplicationRecord
  has_many :items
  has_ancestry

  validates :name, presence: true
end

The item model looks like this.

item.rb


class Item < ApplicationRecord
  belongs_to :category
end

Click here for the migration file that sets the category table.

0000000_create_categories


class CreateCategories < ActiveRecord::Migration[6.0]
  def change
    create_table :categories do |t|
      t.string :name, null: false
      t.string :ancestry
      t.timestamps
    end
  end
end
id name ancestry

You now have a data table like this. As you will see later, the ancestry at the top level will be null, so ** do not add null: false to the ancestry column of the category table **.

Don't forget to migrate ~~

rails db:migrate

3. Write the data to be used in the seeds.rb file

The following article may be helpful for what seeds.rb is. [Introduction to Rails] Summary of how to use seed

However, for the time being, I proceeded with "it seems to set the initial value of the data".

Now, how to write in seeds.rb, I will explain with a part first.

seeds.rb


/This is the first hierarchy/
lady = Category.create(name: "Women")
men = Category.create(name: "mens")
~Omitted below~

/"Women"Second hierarchy tied to/
lady_1 = lady.children.create(name: "tops")
lady_2 = lady.children.create(name: "Jacket/outer")
~Omitted below~

/"tops"Third hierarchy linked to/
lady_1.children.create([{name: "T-shirt/Cut and sew(Short sleeves/Sleeveless)"},{name: "T-shirt/Cut and sew(Seven minutes/Long sleeves)"},{name: "shirt/blouse(Short sleeves/Sleeveless)"},{name: "shirt/blouse(Seven minutes/Long sleeves)"},{name: "ポロshirt"},{name: "camisole"},{name: "Tank top"},{name: "Halter neck"},{name: "knit/sweater"},{name: "Tunic"},{name: "cardigan/Bolero"},{name: "ensemble"},{name: "Best/Gillet"},{name: "Parker"},{name: "trainer/sweat"},{name: "Bare top/Tube top"},{name: "Jersey"},{name: "Other"}])
~Omitted below~

in this way,

  1. Use the create method to create the top hierarchy (parent element) and assign it to a variable. (Here lady)
  2. Next, use ** children.create ** for that variable to create a second hierarchy (child element) and assign it to another variable (here lady_1 or lady_2).
  3. Use children.create for the variable in the same way to create the third hierarchy (grandchild element) (no problem even if you do not assign the variable) It is a flow.

The idea is simple, but writing all the code is quite difficult (the total number of data exceeds 1200), so I will put all the code at the end of the article.

After entering all the data rails db: seed

rails db:seed

The sequence pro should look like this. Image from Gyazo

As mentioned earlier, the parent element ancestry will be NULL. And, as shown below, the ancestry of the child element is displayed as the id of the parent element, and the ancestry of the grandchild element is displayed as the number id of the parent element / id of the child element.

id name ancestry
1 Women NULL
~~ ~~ ~~
14 tops 1
~~ ~~ ~~
33 T-shirt 1/14

That's it! !!

The rest is the work of creating a form using this data.

Did you fail in this process? What i did

Some people may make the same mistake, so just a little at the end.

In my case, I tried rails db: seed once with only the ladies' data, and confirmed that it was reflected in the sequence pro.

After that, after writing the continuation, if rails db: seed ...

** The ladies' data that was reflected the first time has been registered again, and it has become duplicated! ** **

So I manipulated mySQL from the terminal to delete the data and did rails db: seed again.

Then ....

** The situation where the ID starts from the serial number of the data that should have been erased! !! ** **

In other words, it started from a number like 1200. By the way, this seems to be due to a function called auto_increment in mySQL, and I had to reset this function once.

I reset the serial number function and rails db: seed, and it was completed successfully. I hope it will be helpful when you modify the data.

Articles that were helpful at this time When erasing data: Delete data Eliminates serial numbers: Difference between TRUNCATE and DELETE

Full code for seeds.rb

lady = Category.create(name: "Women")
men = Category.create(name: "mens")
baby_kids = Category.create(name: "Baby / Kids")
interior_residence_accessory = Category.create(name: "Interior / house / accessories")
book_music_game = Category.create(name: "Books / music / games")
toy_hobby_goods = Category.create(name: "Toys, hobbies and goods")
cosme_perfume_beauty = Category.create(name: "Cosmetics / perfume / beauty")
appliance_smartphone_camera = Category.create(name: "Home appliances, smartphones, cameras")
sport_leisure = Category.create(name: "sport, leisure")
handmade = Category.create(name: "Handmade")
ticket = Category.create(name: "ticket")
car_motorcycle = Category.create(name: "Car / Motorcycle / Bicycle")
others = Category.create(name: "Other")

lady_1 = lady.children.create(name: "tops")
lady_2 = lady.children.create(name: "Jacket/outer")
lady_3 = lady.children.create(name: "Pants")
lady_4 = lady.children.create(name: "skirt")
lady_5 = lady.children.create(name: "one piece")
lady_6 = lady.children.create(name: "shoes")
lady_7 = lady.children.create(name: "Room wear/pajamas")
lady_8 = lady.children.create(name: "Legwear")
lady_9 = lady.children.create(name: "hat")
lady_10 = lady.children.create(name: "bag")
lady_11 = lady.children.create(name: "Accessories")
lady_12 = lady.children.create(name: "hair accessory")
lady_13 = lady.children.create(name: "Accessories")
lady_14 = lady.children.create(name: "clock")
lady_15 = lady.children.create(name: "wig/Extension")
lady_16 = lady.children.create(name: "yukata/Swimsuit")
lady_17 = lady.children.create(name: "suit/formal/dress")
lady_18 = lady.children.create(name: "Maternity")
lady_19 = lady.children.create(name: "Other")

lady_1.children.create([{name: "T-shirt/Cut and sew(Short sleeves/Sleeveless)"},{name: "T-shirt/Cut and sew(Seven minutes/Long sleeves)"},{name: "shirt/blouse(Short sleeves/Sleeveless)"},{name: "shirt/blouse(Seven minutes/Long sleeves)"},{name: "ポロshirt"},{name: "camisole"},{name: "Tank top"},{name: "Halter neck"},{name: "knit/sweater"},{name: "Tunic"},{name: "cardigan/Bolero"},{name: "ensemble"},{name: "Best/Gillet"},{name: "Parker"},{name: "trainer/sweat"},{name: "Bare top/Tube top"},{name: "Jersey"},{name: "Other"}])
lady_2.children.create([{name: "tailored jacket"},{name: "Collarless jacket"},{name: "G Jean/Denim Jacket"},{name: "leather jacket"},{name: "Down jacket"},{name: "Riders jacket"},{name: "Military jacket"},{name: "Down vest"},{name: "jumper/Blouson"},{name: "poncho"},{name: "Long coat"},{name: "trench coat"},{name: "Duffle coat"},{name: "pea coat"},{name: "Chester coat"},{name: "Mod coat"},{name: "Sukajan"},{name: "fur/Fur coat"},{name: "Spring coat"},{name: "Sukajan"},{name: "Other"}])
lady_3.children.create([{name: "denim/jeans"},{name: "Shorts"},{name: "Casual pants"},{name: "Half pants"},{name: "Chino pants"},{name: "Work pants/cargo pants"},{name: "Cropped pants"},{name: "overalls/Overalls"},{name: "All-in-one"},{name: "Saruel pants"},{name: "Gaucho pants"},{name: "Other"}])
lady_4.children.create([{name: "Mini skirt"},{name: "Knee length skirt"},{name: "Long skirt"},{name: "Culottes"},{name: "Other"}])
lady_5.children.create([{name: "Mini dress"},{name: "Knee length dress"},{name: "Long dress"},{name: "Other"}])
lady_6.children.create([{name: "High heels/pumps"},{name: "boots"},{name: "Sandals"},{name: "sneakers"},{name: "Mule"},{name: "Moccasins"},{name: "loafers/Leather shoes"},{name: "Flat shoes/Ballet shoes"},{name: "Boots/Rain shoes"},{name: "Other"}])
lady_7.children.create([{name: "pajamas"},{name: "Room wear"}])
lady_8.children.create([{name: "socks"},{name: "spats/leggings"},{name: "stockings/tights"},{name: "Leg warmers"},{name: "Other"}])
lady_9.children.create([{name: "Knit cap/Beanie"},{name: "hat"},{name: "hunting/beret"},{name: "cap"},{name: "Newsboy cap"},{name: "Straw hat"},{name: "Other"}])
lady_10.children.create([{name: "Handbag"},{name: "tote bag"},{name: "Eco bag"},{name: "Ruck sack/Backpack"},{name: "Boston bag"},{name: "Sports bag"},{name: "Shoulder bag"},{name: "Clutch bag"},{name: "Pouch/Vanity"},{name: "body bag/Waist bag"},{name: "Mother's bag"},{name: "Messenger bag"},{name: "Business bag"},{name: "Travel bag/Carry Bag"},{name: "Shop bag"},{name: "Kimono bag"},{name: "Basket bag"},{name: "Other"}])
lady_11.children.create([{name: "necklace"},{name: "bracelet"},{name: "Bangle/Wristband"},{name: "ring"},{name: "Earrings(For one ear)"},{name: "Earrings(For both ears)"},{name: "イヤring"},{name: "anklet"},{name: "brooch/corsage"},{name: "charm"},{name: "Other"}])
lady_12.children.create([{name: "Hair rubber/Scrunchie"},{name: "hair band/Katyusha"},{name: "hairpin"},{name: "Other"}])
lady_13.children.create([{name: "long wallet"},{name: "Folded wallet"},{name: "coin purse/Coin purse"},{name: "business card holder/Pass holder"},{name: "key case"},{name: "key ring"},{name: "gloves/Arm cover"},{name: "handkerchief"},{name: "belt"},{name: "Scarf/shawl"},{name: "Stall/Snood"},{name: "bandana/scarf"},{name: "neck warmer"},{name: "suspenders"},{name: "sunglasses/Glasses"},{name: "Mobile case/cover"},{name: "Notebook"},{name: "イヤScarf"},{name: "umbrella"},{name: "Raincoat/poncho"},{name: "mirror"},{name: "Tobacco goods"},{name: "Other"}])
lady_14.children.create([{name: "Watches(analog)"},{name: "Watches(Digital)"},{name: "Rubber belt"},{name: "Leather belt"},{name: "Metal belt"},{name: "Other"}])
lady_15.children.create([{name: "Bangs wig"},{name: "Long straight"},{name: "Long curl"},{name: "Short straight"},{name: "Short curl"},{name: "Other"}])
lady_16.children.create([{name: "yukata"},{name: "kimono"},{name: "Furisode"},{name: "Nagajuban/Semi-juban"},{name: "Swimsuit separate"},{name: "Swimsuit dress"},{name: "Swimsuit for sports"},{name: "Other"}])
lady_17.children.create([{name: "Skirt suit top and bottom"},{name: "Pants suit top and bottom"},{name: "dress"},{name: "Party bag"},{name: "shoes"},{name: "wedding"},{name: "Other"}])
lady_18.children.create([{name: "tops"},{name: "outer"},{name: "inner"},{name: "one piece"},{name: "Pants/spats"},{name: "skirt"},{name: "pajamas"},{name: "Breastfeeding clothes"},{name: "Other"}])
lady_19.children.create([{name: "Cosplay"},{name: "underwear"},{name: "Other"}])

men_1 = men.children.create(name: "tops")
men_2 = men.children.create(name: "Jacket/outer")
men_3 = men.children.create(name: "Pants")
men_4 = men.children.create(name: "shoes")
men_5 = men.children.create(name: "bag")
men_6 = men.children.create(name: "suit")
men_7 = men.children.create(name: "hat")
men_8 = men.children.create(name: "Accessories")
men_9 = men.children.create(name: "Accessories")
men_10 = men.children.create(name: "clock")
men_11 = men.children.create(name: "Swimsuit")
men_12 = men.children.create(name: "Legwear")
men_13 = men.children.create(name: "underwear")
men_14 = men.children.create(name: "Other")

men_1.children.create([{name: "T-shirt/Cut and sew(Short sleeves/Sleeveless)"},{name: "T-shirt/Cut and sew(Seven minutes/Long sleeves)"},{name: "shirt"},{name: "ポロshirt"},{name: "Tank top"},{name: "knit/sweater"},{name: "Parker"},{name: "cardigan"},{name: "sweat"},{name: "Jersey"},{name: "Best"},{name: "Other"}])
men_2.children.create([{name: "tailored jacket"},{name: "Collarless jacket"},{name: "G Jean/Denim Jacket"},{name: "leather jacket"},{name: "Down jacket"},{name: "Riders jacket"},{name: "Military jacket"},{name: "Nylon jacket"},{name: "Flight jacket"},{name: "Duffle coat"},{name: "pea coat"},{name: "Bal collar coat"},{name: "trench coat"},{name: "Mod coat"},{name: "Chester coat"},{name: "Sukajan"},{name: "Sukajan"},{name: "Blouson"},{name: "Mountain parka"},{name: "Down vest"},{name: "poncho"},{name: "Coverall"},{name: "Other"}])
men_3.children.create([{name: "denim/jeans"},{name: "Work pants/cargo pants"},{name: "slacks"},{name: "Chino pants"},{name: "Shorts"},{name: "Painter pants"},{name: "Saruel pants"},{name: "Overalls"},{name: "Other"}])
men_4.children.create([{name: "sneakers"},{name: "Sandals"},{name: "boots"},{name: "Moccasins"},{name: "dress/business"},{name: "Boots/Rain shoes"},{name: "Deck shoes"},{name: "Other"}])
men_5.children.create([{name: "Shoulder bag"},{name: "tote bag"},{name: "Boston bag"},{name: "Ruck sack/Backpack"},{name: "Waist pouch"},{name: "Body bag"},{name: "Drum bag"},{name: "Business bag"},{name: "Travel bag"},{name: "Messenger bag"},{name: "Eco bag"},{name: "Other"}])
men_6.children.create([{name: "Suit jacket"},{name: "Suit vest"},{name: "slacks"},{name: "setup"},{name: "Other"}])
men_7.children.create([{name: "cap"},{name: "hat"},{name: "ニットcap/Beanie"},{name: "hunting/beret"},{name: "Newsboy cap"},{name: "Sun visor"},{name: "Other"}])
men_8.children.create([{name: "necklace"},{name: "bracelet"},{name: "Bangle/Wristband"},{name: "ring"},{name: "Earrings(For one ear)"},{name: "Earrings(For both ears)"},{name: "anklet"},{name: "Other"}])
men_9.children.create([{name: "long wallet"},{name: "Folded wallet"},{name: "Money clip"},{name: "coin purse/Coin purse"},{name: "business card holder/Pass holder"},{name: "key case"},{name: "key ring"},{name: "tie"},{name: "gloves"},{name: "handkerchief"},{name: "belt"},{name: "Scarf"},{name: "Stall"},{name: "bandana"},{name: "neck warmer"},{name: "suspenders"},{name: "Wallet chain"},{name: "sunglasses/Glasses"},{name: "Mobile case/cover"},{name: "Notebook"},{name: "strap"},{name: "tieピン"},{name: "Cufflinks"},{name: "イヤScarf"},{name: "umbrella"},{name: "Raincoat"},{name: "mirror"},{name: "Tobacco goods"},{name: "Other"}])
men_10.children.create([{name: "Watches(analog)"},{name: "Watches(Digital)"},{name: "Rubber belt"},{name: "Leather belt"},{name: "Metal belt"},{name: "Other"}])
men_11.children.create([{name: "General swimwear"},{name: "For sports"},{name: "Accessories"},{name: "Other"}])
men_12.children.create([{name: "socks"},{name: "leggings/spats"},{name: "Leg warmers"},{name: "Other"}])
men_13.children.create([{name: "trunks"},{name: "boxer shorts"},{name: "Other"}])
men_14.children.create([{name: "all"}])

baby_kids_1 = baby_kids.children.create(name: "Baby clothes(For girls) ~95cm")
baby_kids_2 = baby_kids.children.create(name: "Baby clothes(For boys) ~95cm")
baby_kids_3 = baby_kids.children.create(name: "Baby clothes(unisex) ~95cm")
baby_kids_4 = baby_kids.children.create(name: "Kids clothes(For girls) 100cm~")
baby_kids_5 = baby_kids.children.create(name: "Kids clothes(For boys) 100cm~")
baby_kids_6 = baby_kids.children.create(name: "Kids clothes(unisex) 100cm~")
baby_kids_7 = baby_kids.children.create(name: "Kids shoes")
baby_kids_8 = baby_kids.children.create(name: "Children's fashion accessories")
baby_kids_9 = baby_kids.children.create(name: "Diapers/toilet/bus")
baby_kids_10 = baby_kids.children.create(name: "Go out/Moving goods")
baby_kids_11 = baby_kids.children.create(name: "Breastfeeding/Meal")
baby_kids_12 = baby_kids.children.create(name: "Baby furniture/bedding/Indoor supplies")
baby_kids_13 = baby_kids.children.create(name: "toy")
baby_kids_14 = baby_kids.children.create(name: "Event/Souvenir")
baby_kids_15 = baby_kids.children.create(name: "Other")

baby_kids_1.children.create([{name: "tops"},{name: "outer"},{name: "Pants"},{name: "skirt"},{name: "one piece"},{name: "Baby dress"},{name: "Swaddle"},{name: "underwear/underwear"},{name: "pajamas"},{name: "Rompers"},{name: "Other"}])
baby_kids_2.children.create([{name: "tops"},{name: "outer"},{name: "Pants"},{name: "Swaddle"},{name: "underwear/underwear"},{name: "pajamas"},{name: "Rompers"},{name: "Other"}])
baby_kids_3.children.create([{name: "tops"},{name: "outer"},{name: "Pants"},{name: "Swaddle"},{name: "underwear/underwear"},{name: "pajamas"},{name: "Rompers"},{name: "Other"}])
baby_kids_4.children.create([{name: "coat"},{name: "Jacket/Outerwear"},{name: "tops(T-shirt/Cut and sew)"},{name: "tops(trainer)"},{name: "tops(Tunic)"},{name: "tops(Tank top)"},{name: "tops(Other)"},{name: "skirt"},{name: "Pants"},{name: "one piece"},{name: "setup"},{name: "pajamas"},{name: "formal/dress"},{name: "Kimono"},{name: "yukata"},{name: "Jinbei"},{name: "Swimsuit"},{name: "Other"}])
baby_kids_5.children.create([{name: "coat"},{name: "Jacket/Outerwear"},{name: "tops(T-shirt/Cut and sew)"},{name: "tops(trainer)"},{name: "tops(Other)"},{name: "Pants"},{name: "setup"},{name: "pajamas"},{name: "formal/dress"},{name: "Kimono"},{name: "yukata"},{name: "Jinbei"},{name: "Swimsuit"},{name: "Other"}])
baby_kids_6.children.create([{name: "coat"},{name: "Jacket/Outerwear"},{name: "tops(T-shirt/Cut and sew)"},{name: "tops(trainer)"},{name: "tops(Other)"},{name: "Bottoms"},{name: "pajamas"},{name: "Other"}])
baby_kids_7.children.create([{name: "sneakers"},{name: "Sandals"},{name: "boots"},{name: "Boots"},{name: "Other"}])
baby_kids_8.children.create([{name: "socks/spats"},{name: "hat"},{name: "apron"},{name: "suspenders"},{name: "tights"},{name: "handkerchief"},{name: "bandana"},{name: "belt"},{name: "Scarf"},{name: "umbrella"},{name: "gloves"},{name: "Bib"},{name: "bag"},{name: "Other"}])
baby_kids_9.children.create([{name: "Diaper supplies"},{name: "Potato/Auxiliary toilet seat"},{name: "Training pants"},{name: "Baby bath"},{name: "Bath supplies"},{name: "Other"}])
baby_kids_10.children.create([{name: "stroller"},{name: "Hugging strap/Sling"},{name: "child seat"},{name: "Other"}])
baby_kids_11.children.create([{name: "milk"},{name: "Baby food"},{name: "Baby tableware"},{name: "Other"}])
baby_kids_12.children.create([{name: "bed"},{name: "futon/blanket"},{name: "chair"},{name: "Chest of drawers"},{name: "Other"}])
baby_kids_13.children.create([{name: "Bath toys"},{name: "Rattle"},{name: "Music box"},{name: "Baby gym"},{name: "Wheelbarrow/Rattling"},{name: "Educational toys"},{name: "Other"}])
baby_kids_14.children.create([{name: "Miyamairi supplies"},{name: "Beginning food supplies"},{name: "album"},{name: "Bill/Foot shape"},{name: "Other"}])
baby_kids_15.children.create([{name: "Mother and child notebook supplies"},{name: "Other"}])

interior_residence_accessory_1 = interior_residence_accessory.children.create(name: "kitchen/Tableware")
interior_residence_accessory_2 = interior_residence_accessory.children.create(name: "bed/mattress")
interior_residence_accessory_3 = interior_residence_accessory.children.create(name: "sofa/sofaベッド")
interior_residence_accessory_4 = interior_residence_accessory.children.create(name: "Chair/chair")
interior_residence_accessory_5 = interior_residence_accessory.children.create(name: "desk/table")
interior_residence_accessory_6 = interior_residence_accessory.children.create(name: "Storage furniture")
interior_residence_accessory_7 = interior_residence_accessory.children.create(name: "Rug/carpet/mat")
interior_residence_accessory_8 = interior_residence_accessory.children.create(name: "curtain/blind")
interior_residence_accessory_9 = interior_residence_accessory.children.create(name: "Light/illumination")
interior_residence_accessory_10 = interior_residence_accessory.children.create(name: "bedding")
interior_residence_accessory_11 = interior_residence_accessory.children.create(name: "Interior accessories")
interior_residence_accessory_12 = interior_residence_accessory.children.create(name: "Season/Annual event")
interior_residence_accessory_13 = interior_residence_accessory.children.create(name: "Other")

interior_residence_accessory_1.children.create([{name: "Tableware"},{name: "kitchenware"},{name: "Storage/Kitchen miscellaneous goods"},{name: "Bento supplies"},{name: "cutlery(Spoon etc.)"},{name: "Table supplies"},{name: "container"},{name: "apron"},{name: "Alcohol goods"},{name: "Water purifier"},{name: "Other"}])
interior_residence_accessory_2.children.create([{name: "Semi-single bed"},{name: "Single Bed"},{name: "Semi-double bed"},{name: "Double bed"},{name: "ワイドDouble bed"},{name: "Queen bed"},{name: "King bed"},{name: "Mattress bed with legs"},{name: "mattress"},{name: "Slatted bed"},{name: "Loft bed/System bed"},{name: "Bunk/Folding bed"},{name: "With storage"},{name: "Other"}])
interior_residence_accessory_3.children.create([{name: "Sofa set"},{name: "Single sofa"},{name: "Love sofa"},{name: "Triple sofa"},{name: "Ottoman"},{name: "Corner sofa"},{name: "Bead sofa/Cushion sofa"},{name: "Low sofa/Floor sofa"},{name: "Sofa bed"},{name: "Reception set"},{name: "Sofa cover"},{name: "Reclining sofa"},{name: "Other"}])
interior_residence_accessory_4.children.create([{name: "General"},{name: "stool"},{name: "Dining chair"},{name: "High back chair"},{name: "Rocking chair"},{name: "Seat chair"},{name: "Folding chair"},{name: "Desk chair"},{name: "Other"}])
interior_residence_accessory_5.children.create([{name: "Kotatsu"},{name: "counter"},{name: "Side table"},{name: "Center table"},{name: "Dining table"},{name: "Table/Chabudai"},{name: "For the outdoors"},{name: "For PC"},{name: "Office desk/student desk"},{name: "Other"}])
interior_residence_accessory_6.children.create([{name: "Living room storage"},{name: "Kitchen storage"},{name: "Entrance/Outdoor storage"},{name: "bus/Toilet storage"},{name: "Book storage"},{name: "Book/CD/DVD storage"},{name: "Wardrobe/Closet storage"},{name: "Telephone stand/Fax stand"},{name: "dresser/Mirror stand"},{name: "shelf/rack"},{name: "Case/box"},{name: "Other"}])
interior_residence_accessory_7.children.create([{name: "Rug"},{name: "carpet"},{name: "ホットcarpet"},{name: "Entrance/Kitchen mat"},{name: "toilet/Bath mat"},{name: "Other"}])
interior_residence_accessory_8.children.create([{name: "curtain"},{name: "blind"},{name: "Roll screen"},{name: "Goodwill"},{name: "Other"}])
interior_residence_accessory_9.children.create([{name: "Fluorescent light/light bulb"},{name: "Ceiling lighting"},{name: "Floor stand"},{name: "Other"}])
interior_residence_accessory_10.children.create([{name: "futon/blanket"},{name: "pillow"},{name: "Sheets/cover"},{name: "Other"}])
interior_residence_accessory_11.children.create([{name: "Trash can"},{name: "Welcome board"},{name: "Music box"},{name: "cushion"},{name: "cushionカバー"},{name: "Slipper rack"},{name: "Tissue box"},{name: "basket/Basket"},{name: "Photo frame"},{name: "magazine rack"},{name: "Mobile"},{name: "Mobile"},{name: "vase"},{name: "ashtray"},{name: "Umbrella stand"},{name: "accessory case"},{name: "Table clock"},{name: "Wall clock/wall clock"},{name: "mirror(Leaning type)"},{name: "mirror(Wall-mounted)"},{name: "ornament"},{name: "Wind chimes"},{name: "plant/観葉plant"},{name: "Other"}])
interior_residence_accessory_12.children.create([{name: "New Year"},{name: "Coming-of-age ceremony"},{name: "Valentine's day"},{name: "Hinamatsuri"},{name: "Children's day"},{name: "Mother's Day"},{name: "Father's Day"},{name: "Father's Day"},{name: "Summer gift/Summer gift"},{name: "summer/summer休み"},{name: "Halloween"},{name: "Respect for the aged day"},{name: "Shichigosan"},{name: "Year-end gift"},{name: "Christmas"},{name: "Winter in general"},{name: "Other"}])
interior_residence_accessory_13.children.create([{name: "all"}])

book_music_game_1 = book_music_game.children.create(name: "Book")
book_music_game_2 = book_music_game.children.create(name: "Cartoon")
book_music_game_3 = book_music_game.children.create(name: "magazine")
book_music_game_4 = book_music_game.children.create(name: "CD")
book_music_game_5 = book_music_game.children.create(name: "DVD/Blu-ray")
book_music_game_6 = book_music_game.children.create(name: "record")
book_music_game_7 = book_music_game.children.create(name: "Video game")

book_music_game_1.children.create([{name: "literature/novel"},{name: "Humanities/society"},{name: "Non-Fiction/Liberal arts"},{name: "map/Travel guide"},{name: "business/Economy"},{name: "business/Economy"},{name: "health/Medicine"},{name: "Computer/IT"},{name: "hobby/Sports/Practical"},{name: "House/living/Parenting"},{name: "Art/Entertainment"},{name: "Foreign books"},{name: "Picture book"},{name: "Reference book"},{name: "Other"}])
book_music_game_2.children.create([{name: "Whole volume set"},{name: "Shonen manga"},{name: "Shojo manga"},{name: "Seinen manga"},{name: "Josei cartoon"},{name: "Doujinshi"},{name: "Other"}])
book_music_game_3.children.create([{name: "Art/Entertainment/Hobby"},{name: "fashion"},{name: "news/Comprehensive"},{name: "hobby/Sports"},{name: "Other"}])
book_music_game_4.children.create([{name: "Japanese music"},{name: "Western music"},{name: "Anime"},{name: "Classic"},{name: "K-POP/Asia"},{name: "Kids/family"},{name: "Other"}])
book_music_game_5.children.create([{name: "Foreign movies"},{name: "Japanese movie"},{name: "Anime"},{name: "TV drama"},{name: "Music"},{name: "comedy/variety"},{name: "Sports/Fitness"},{name: "Kids/family"},{name: "Other"}])
book_music_game_6.children.create([{name: "Japanese music"},{name: "Western music"},{name: "Other"}])
book_music_game_7.children.create([{name: "Home video game console"},{name: "Home video game software"},{name: "Portable game body"},{name: "Handheld game software"},{name: "PC games"},{name: "Other"}])

toy_hobby_goods_1 = toy_hobby_goods.children.create(name: "toy")
toy_hobby_goods_2 = toy_hobby_goods.children.create(name: "Talent goods")
toy_hobby_goods_3 = toy_hobby_goods.children.create(name: "Comic/Anime goods")
toy_hobby_goods_4 = toy_hobby_goods.children.create(name: "Trading cards")
toy_hobby_goods_5 = toy_hobby_goods.children.create(name: "Figure")
toy_hobby_goods_6 = toy_hobby_goods.children.create(name: "Musical instrument/Equipment")
toy_hobby_goods_7 = toy_hobby_goods.children.create(name: "collection")
toy_hobby_goods_8 = toy_hobby_goods.children.create(name: "military")
toy_hobby_goods_9 = toy_hobby_goods.children.create(name: "Work of art")
toy_hobby_goods_10 = toy_hobby_goods.children.create(name: "Art supplies")
toy_hobby_goods_11 = toy_hobby_goods.children.create(name: "Other")

toy_hobby_goods_1.children.create([{name: "Character Goods"},{name: "Plush Doll"},{name: "Accessories/Accessories"},{name: "model/Plastic model"},{name: "Minicar"},{name: "Radio control"},{name: "Plastic model"},{name: "Hobby radio control"},{name: "鉄道model"},{name: "Other"}])
toy_hobby_goods_2.children.create([{name: "Idol"},{name: "Musician"},{name: "talent/Comedian"},{name: "athlete"},{name: "Other"}])
toy_hobby_goods_3.children.create([{name: "strap"},{name: "key ring"},{name: "badge"},{name: "card"},{name: "clear file"},{name: "Poster"},{name: "towel"},{name: "Other"}])
toy_hobby_goods_4.children.create([{name: "Yu-Gi-Oh"},{name: "Magic: The Gathering"},{name: "Pokemon card game"},{name: "duel Masters"},{name: "battle spirit"},{name: "PriPara"},{name: "Aikatsu"},{name: "Card fight!!Vanguard"},{name: "Weiss Schwarz"},{name: "Professional Baseball Owners League"},{name: "Baseball Heroes"},{name: "Dragon Ball"},{name: "sleeve"},{name: "Other"}])
toy_hobby_goods_5.children.create([{name: "Comic/Anime"},{name: "Special effects"},{name: "Game character"},{name: "SF/Fantasy/Horror"},{name: "American comics"},{name: "Sports"},{name: "military"},{name: "Other"}])
toy_hobby_goods_6.children.create([{name: "Electric guitar"},{name: "Acoustic guitar"},{name: "base"},{name: "effector"},{name: "Amplifier"},{name: "Stringed instrument"},{name: "Wind instrument"},{name: "Keyboard instrument"},{name: "Percussion instrument"},{name: "Japanese musical instrument"},{name: "Musical score/Score"},{name: "recording/PA equipment"},{name: "DJ equipment"},{name: "DTM/DAW"},{name: "Other"}])
toy_hobby_goods_7.children.create([{name: "armor"},{name: "Used stamps/Official postcard"},{name: "Old currency/Gold coins/Silver coin/Commemorative coin"},{name: "Printed matter"},{name: "Novelty goods"},{name: "Other"}])
toy_hobby_goods_8.children.create([{name: "Toy gun"},{name: "Personal equipment"},{name: "Other"}])
toy_hobby_goods_9.children.create([{name: "Pottery"},{name: "Glass"},{name: "Lacquer art"},{name: "Metal craft"},{name: "Painting/Tapestry"},{name: "Prints"},{name: "Sculpture/object"},{name: "book"},{name: "Photo"},{name: "Other"}])
toy_hobby_goods_10.children.create([{name: "Art supplies"},{name: "Picture frame"},{name: "Other"}])
toy_hobby_goods_11.children.create([{name: "Playing cards/UNO"},{name: "Karuta/Hyakunin Isshu"},{name: "darts"},{name: "Billiards"},{name: "Mahjong"},{name: "puzzle/ジグソーpuzzle"},{name: "Go/Shogi"},{name: "Othello/chess"},{name: "Game of Life"},{name: "baseball/Soccer game"},{name: "Sports"},{name: "Tricycle/vehicle"},{name: "Yoyo"},{name: "Model making supplies"},{name: "Railroad"},{name: "aircraft"},{name: "Amateur radio"},{name: "pachinko/Pachislot"},{name: "Other"}])

cosme_perfume_beauty_1 = cosme_perfume_beauty.children.create(name: "Base makeup")
cosme_perfume_beauty_2 = cosme_perfume_beauty.children.create(name: "Makeup")
cosme_perfume_beauty_3 = cosme_perfume_beauty.children.create(name: "Nail care")
cosme_perfume_beauty_4 = cosme_perfume_beauty.children.create(name: "perfume")
cosme_perfume_beauty_5 = cosme_perfume_beauty.children.create(name: "skin care/Basic cosmetics")
cosme_perfume_beauty_6 = cosme_perfume_beauty.children.create(name: "hair care")
cosme_perfume_beauty_7 = cosme_perfume_beauty.children.create(name: "body care")
cosme_perfume_beauty_8 = cosme_perfume_beauty.children.create(name: "Oral care")
cosme_perfume_beauty_9 = cosme_perfume_beauty.children.create(name: "relaxation")
cosme_perfume_beauty_10 = cosme_perfume_beauty.children.create(name: "diet")
cosme_perfume_beauty_11 = cosme_perfume_beauty.children.create(name: "Other")

cosme_perfume_beauty_1.children.create([{name: "Foundation"},{name: "Makeup base"},{name: "Control color"},{name: "BB cream"},{name: "CC cream"},{name: "Concealer"},{name: "Face powder"},{name: "Trial set/sample"},{name: "Other"}])
cosme_perfume_beauty_2.children.create([{name: "eye shadow"},{name: "lipstick"},{name: "Lip gloss"},{name: "Lip liner"},{name: "cheek"},{name: "Face color"},{name: "mascara"},{name: "eyeliner"},{name: "False eyelashes"},{name: "Eyebrow pencil"},{name: "Powder eyebrow"},{name: "眉mascara"},{name: "Trial set/sample"},{name: "Makeup tools/Makeup accessories"},{name: "Facial supplies/Facial roller"},{name: "Other"}])
cosme_perfume_beauty_3.children.create([{name: "Nail color"},{name: "Color gel"},{name: "Nail base coat/Top coat"},{name: "Nail art supplies"},{name: "Nail parts"},{name: "Nail tips/False nails"},{name: "Care tools"},{name: "Nail polish remover"},{name: "Other"}])
cosme_perfume_beauty_4.children.create([{name: "perfume(for women)"},{name: "perfume(Men's)"},{name: "unisex"},{name: "Body mist"},{name: "Other"}])
cosme_perfume_beauty_5.children.create([{name: "Toner/lotion"},{name: "Emulsion/milk"},{name: "Essence"},{name: "Face cream"},{name: "Facial wash"},{name: "cleansing/Makeup Remover"},{name: "pack/Face mask"},{name: "Gel/gel"},{name: "booster/Introductory liquid"},{name: "Eye care"},{name: "Lip care"},{name: "Trial set/sample"},{name: "Face wash goods"},{name: "Other"}])
cosme_perfume_beauty_6.children.create([{name: "shampoo"},{name: "treatment"},{name: "conditioner"},{name: "rinse"},{name: "Styling agent"},{name: "Coloring agent"},{name: "brush"},{name: "Other"}])
cosme_perfume_beauty_7.children.create([{name: "oil/cream"},{name: "ハンドcream"},{name: "lotion"},{name: "Sunscreen/サンoil"},{name: "Body Soap"},{name: "Bath additive"},{name: "Antiperspirant/deodorant"},{name: "foot care"},{name: "Other"}])
cosme_perfume_beauty_8.children.create([{name: "Prevention of bad breath/Etiquette supplies"},{name: "toothbrush"},{name: "Other"}])
cosme_perfume_beauty_9.children.create([{name: "Essential oil"},{name: "Air freshener"},{name: "Incense/Censer"},{name: "Candle"},{name: "Relaxation goods"},{name: "Other"}])
cosme_perfume_beauty_10.children.create([{name: "Diet food"},{name: "Exercise supplies"},{name: "Weight scale"},{name: "Body fat scale"},{name: "Other"}])
cosme_perfume_beauty_11.children.create([{name: "Health products"},{name: "Nurse/Nursing care products"},{name: "First aid/Hygiene products"},{name: "Other"}])

appliance_smartphone_camera_1 = appliance_smartphone_camera.children.create(name: "smartphone/mobile phone")
appliance_smartphone_camera_2 = appliance_smartphone_camera.children.create(name: "Smartphone accessories")
appliance_smartphone_camera_3 = appliance_smartphone_camera.children.create(name: "PC/Tablet")
appliance_smartphone_camera_4 = appliance_smartphone_camera.children.create(name: "camera")
appliance_smartphone_camera_5 = appliance_smartphone_camera.children.create(name: "TV set/Video equipment")
appliance_smartphone_camera_6 = appliance_smartphone_camera.children.create(name: "Audio equipment")
appliance_smartphone_camera_7 = appliance_smartphone_camera.children.create(name: "Beauty/health")
appliance_smartphone_camera_8 = appliance_smartphone_camera.children.create(name: "Air conditioning/air conditioning")
appliance_smartphone_camera_9 = appliance_smartphone_camera.children.create(name: "Home appliances")
appliance_smartphone_camera_10 = appliance_smartphone_camera.children.create(name: "Other")

appliance_smartphone_camera_1.children.create([{name: "Smartphone body"},{name: "battery/Charger"},{name: "Mobile phone body"},{name: "PHS body"},{name: "Other"}])
appliance_smartphone_camera_2.children.create([{name: "Android case"},{name: "iPhone case"},{name: "cover"},{name: "earphone jack"},{name: "strap"},{name: "the film"},{name: "Selfie stick"},{name: "Other"}])
appliance_smartphone_camera_3.children.create([{name: "Tablet"},{name: "Laptop"},{name: "Desktop PC"},{name: "display"},{name: "Ebook reader"},{name: "PC peripherals"},{name: "PC parts"},{name: "Other"}])
appliance_smartphone_camera_4.children.create([{name: "Digital camera"},{name: "Video camera"},{name: "lens(Single focus)"},{name: "lens(zoom)"},{name: "Film camera"},{name: "surveillance camera"},{name: "Other"}])
appliance_smartphone_camera_5.children.create([{name: "TV set"},{name: "projector"},{name: "Blu-ray recorder"},{name: "DVD recorder"},{name: "Blu-ray player"},{name: "DVD player"},{name: "Video cable"},{name: "Other"}])
appliance_smartphone_camera_6.children.create([{name: "Portable player"},{name: "Earphones"},{name: "Headphones"},{name: "Amplifier"},{name: "speaker"},{name: "cable/shield"},{name: "radio"},{name: "Other"}])
appliance_smartphone_camera_7.children.create([{name: "Hair Dryer"},{name: "hair iron"},{name: "Beauty Equipment"},{name: "Electric shaver"},{name: "electric toothbrush"},{name: "Other"}])
appliance_smartphone_camera_8.children.create([{name: "Air conditioner"},{name: "Air cleaner"},{name: "humidifier"},{name: "Fan"},{name: "Dehumidifier"},{name: "Fan heater"},{name: "Electric heater"},{name: "Oil heater"},{name: "Stove"},{name: "Hot carpet"},{name: "Kotatsu"},{name: "electric blanket"},{name: "Other"}])
appliance_smartphone_camera_9.children.create([{name: "refrigerator"},{name: "Washing machine"},{name: "rice cooker"},{name: "microwave/oven"},{name: "Cooking equipment"},{name: "Iron"},{name: "Vacuum cleaner"},{name: "Espresso machine"},{name: "coffee maker"},{name: "Clothes dryer"},{name: "Other"}])
appliance_smartphone_camera_10.children.create([{name: "Other"}])

sport_leisure_1 = sport_leisure.children.create(name: "golf")
sport_leisure_2 = sport_leisure.children.create(name: "Phishing")
sport_leisure_3 = sport_leisure.children.create(name: "bicycle")
sport_leisure_4 = sport_leisure.children.create(name: "training/exercise")
sport_leisure_5 = sport_leisure.children.create(name: "baseball")
sport_leisure_6 = sport_leisure.children.create(name: "Football/Futsal")
sport_leisure_7 = sport_leisure.children.create(name: "tennis")
sport_leisure_8 = sport_leisure.children.create(name: "snow board")
sport_leisure_9 = sport_leisure.children.create(name: "Skiing")
sport_leisure_10 = sport_leisure.children.create(name: "Other sports")
sport_leisure_11 = sport_leisure.children.create(name: "Outdoor")
sport_leisure_12 = sport_leisure.children.create(name: "Other")

sport_leisure_1.children.create([{name: "club"},{name: "wear(Men's)"},{name: "wear(for women)"},{name: "bag"},{name: "shoes(Men's)"},{name: "shoes(for women)"},{name: "Accessories"},{name: "Other"}])
sport_leisure_2.children.create([{name: "rod"},{name: "reel"},{name: "Lure supplies"},{name: "wear"},{name: "fishing line/line"},{name: "Other"}])
sport_leisure_3.children.create([{name: "Bicycle body"},{name: "wear"},{name: "parts"},{name: "Accessories"},{name: "bag"},{name: "tool/maintenance"},{name: "Other"}])
sport_leisure_4.children.create([{name: "running"},{name: "walking"},{name: "yoga"},{name: "Training equipment"},{name: "Other"}])
sport_leisure_5.children.create([{name: "Wear"},{name: "shoes"},{name: "Gloves"},{name: "bat"},{name: "Accessories"},{name: "Armor"},{name: "Practice equipment"},{name: "Commemorative goods"},{name: "Support goods"},{name: "Other"}])
sport_leisure_6.children.create([{name: "Wear"},{name: "shoes"},{name: "ball"},{name: "Accessories"},{name: "Commemorative goods"},{name: "Support goods"},{name: "Other"}])
sport_leisure_7.children.create([{name: "racket(For rigid type)"},{name: "racket(For softball)"},{name: "Wear"},{name: "shoes"},{name: "ball"},{name: "Accessories"},{name: "Commemorative goods"},{name: "Support goods"},{name: "Other"}])
sport_leisure_8.children.create([{name: "board"},{name: "binding"},{name: "boots(Men's)"},{name: "boots(for women)"},{name: "boots(For children)"},{name: "wear/Equipment(Men's)"},{name: "wear/Equipment(for women)"},{name: "wear/Equipment(For children)"},{name: "Accessories"},{name: "bag"},{name: "Other"}])
sport_leisure_9.children.create([{name: "Board"},{name: "boots(Men's)"},{name: "boots(for women)"},{name: "boots(For children)"},{name: "binding"},{name: "wear(Men's)"},{name: "wear(for women)"},{name: "wear(For children)"},{name: "stock"},{name: "Other"}])
sport_leisure_10.children.create([{name: "dance/ballet"},{name: "surfing"},{name: "basketball"},{name: "badminton"},{name: "volleyball"},{name: "skateboard"},{name: "Athletics"},{name: "rugby"},{name: "American Football"},{name: "boxing"},{name: "Bowling"},{name: "Other"}])
sport_leisure_11.children.create([{name: "tent/Tarp"},{name: "Light/lanthanum"},{name: "sleeping bag/bedding"},{name: "table/chair"},{name: "Stove/Stove"},{name: "kitchenware"},{name: "Tableware"},{name: "Mountaineering equipment"},{name: "Other"}])
sport_leisure_12.children.create([{name: "Travel goods"},{name: "Other"}])

handmade_1 = handmade.children.create(name: "Accessories(for women)")
handmade_2 = handmade.children.create(name: "fashion/Accessories")
handmade_3 = handmade.children.create(name: "Accessories/clock")
handmade_4 = handmade.children.create(name: "Daily necessities/interior")
handmade_5 = handmade.children.create(name: "hobby/toy")
handmade_6 = handmade.children.create(name: "Kids/baby")
handmade_7 = handmade.children.create(name: "Material/material")
handmade_8 = handmade.children.create(name: "Derivative work")
handmade_9 = handmade.children.create(name: "Other")

handmade_1.children.create([{name: "Earrings"},{name: "Earrings"},{name: "necklace"},{name: "bracelet"},{name: "ring"},{name: "charm"},{name: "Hair rubber"},{name: "anklet"},{name: "Other"}])
handmade_2.children.create([{name: "bag(for women)"},{name: "bag(Men's)"},{name: "wallet(for women)"},{name: "wallet(Men's)"},{name: "Fashion accessories"},{name: "Other"}])
handmade_3.children.create([{name: "Accessories(Men's)"},{name: "clock(for women)"},{name: "clock(Men's)"},{name: "Other"}])
handmade_4.children.create([{name: "Kitchen utensils"},{name: "furniture"},{name: "stationery"},{name: "Art/Photo"},{name: "aroma/Candle"},{name: "flour/Garden"},{name: "Other"}])
handmade_5.children.create([{name: "Craft/Cloth products"},{name: "toy/doll"},{name: "Other"}])
handmade_6.children.create([{name: "Fashion accessories"},{name: "Bib/Bib"},{name: "Outing supplies"},{name: "Name tag"},{name: "Other"}])
handmade_7.children.create([{name: "Various parts"},{name: "Cloth/yarn"},{name: "Paper pattern/pattern"},{name: "Other"}])
handmade_8.children.create([{name: "Ingress"},{name: "Creators Space Brothers"},{name: "Other"},{name: "ticket"},{name: "all"}])
handmade_9.children.create([{name: "all"}])

ticket_1 = ticket.children.create(name: "musics")
ticket_2 = ticket.children.create(name: "Sports")
ticket_3 = ticket.children.create(name: "theater/Performing arts")
ticket_4 = ticket.children.create(name: "Event")
ticket_5 = ticket.children.create(name: "movies")
ticket_6 = ticket.children.create(name: "Facility use ticket")
ticket_7 = ticket.children.create(name: "Complimentary ticket/Discount ticket")
ticket_8 = ticket.children.create(name: "Other")

ticket_1.children.create([{name: "Male idol"},{name: "Female idol"},{name: "Korean"},{name: "Domestic artist"},{name: "Overseas artist"},{name: "Music festival"},{name: "Voice actor/Anime"},{name: "Other"}])
ticket_2.children.create([{name: "Football"},{name: "baseball"},{name: "tennis"},{name: "Martial arts/wrestling"},{name: "Sumo/martial arts"},{name: "golf"},{name: "volleyball"},{name: "basketball"},{name: "Motor sports"},{name: "Winter sports"},{name: "Other"}])
ticket_3.children.create([{name: "musical"},{name: "theater"},{name: "traditional culture"},{name: "Rakugo"},{name: "comedy"},{name: "Opera"},{name: "Circus"},{name: "ballet"},{name: "Other"}])
ticket_4.children.create([{name: "Voice actor/Anime"},{name: "Kids/family"},{name: "talk show/Lecture"},{name: "Other"}])
ticket_5.children.create([{name: "Japanese movie"},{name: "Western movies"},{name: "Other"}])
ticket_6.children.create([{name: "amusement park/Theme park"},{name: "Museum/Museum"},{name: "Ski resort"},{name: "Golf course"},{name: "Fitness club"},{name: "Pool"},{name: "Bowling alley"},{name: "Aquarium"},{name: "Zoo"},{name: "Other"}])
ticket_7.children.create([{name: "shopping"},{name: "Restaurant/Meal ticket"},{name: "Hood/Drink voucher"},{name: "Accommodation voucher"},{name: "Other"}])
ticket_8.children.create([{name: "all"}])

car_motorcycle_1 = car_motorcycle.children.create(name: "Car body")
car_motorcycle_2 = car_motorcycle.children.create(name: "Auto tires/wheel")
car_motorcycle_3 = car_motorcycle.children.create(name: "Auto parts")
car_motorcycle_4 = car_motorcycle.children.create(name: "Auto accessories")
car_motorcycle_5 = car_motorcycle.children.create(name: "Motorcycle body")
car_motorcycle_6 = car_motorcycle.children.create(name: "Motorcycle parts")
car_motorcycle_7 = car_motorcycle.children.create(name: "Motorcycle accessories")

car_motorcycle_1.children.create([{name: "Domestic car body"},{name: "Foreign car body"}])
car_motorcycle_2.children.create([{name: "tire/Wheel set"},{name: "tire"},{name: "wheel"},{name: "Other"}])
car_motorcycle_3.children.create([{name: "suspension"},{name: "brake"},{name: "Exterior, aero parts"},{name: "Light"},{name: "Interior parts, seats"},{name: "Steering"},{name: "Muffler / exhaust system"},{name: "Engine, supercharger, cooling device"},{name: "Clutch, mission, drive system"},{name: "Electrical components"},{name: "Reinforcement parts"},{name: "General-purpose parts"},{name: "Parts for foreign automobiles"},{name: "Other"}])
car_motorcycle_4.children.create([{name: "Car accessories"},{name: "Car navigation"},{name: "Car Audio"},{name: "External accessories"},{name: "Maintenance supplies"},{name: "child seat"},{name: "drive recorder"},{name: "Radar detector"},{name: "catalog/manual"},{name: "Security"},{name: "ETC"},{name: "Other"}])
car_motorcycle_5.children.create([{name: "all"}])
car_motorcycle_6.children.create([{name: "tire"},{name: "Scarf"},{name: "Engine, cooling system"},{name: "Cowl, fender, exterior"},{name: "suspension"},{name: "wheel"},{name: "Sheet"},{name: "brake"},{name: "tank"},{name: "Lights, blinkers"},{name: "Chain, sprocket, drive train"},{name: "Meter"},{name: "Electrical system"},{name: "mirror"},{name: "Parts for foreign motorcycles"},{name: "Other"}])
car_motorcycle_7.children.create([{name: "Helmet/shield"},{name: "Bike wear/Equipment"},{name: "Accessories"},{name: "maintenance"},{name: "catalog/manual"},{name: "Other"}])

others_1 = others.children.create(name: "Bulk sale")
others_2 = others.children.create(name: "Pet Supplies")
others_3 = others.children.create(name: "Food")
others_4 = others.children.create(name: "Beverage/Liquor")
others_5 = others.children.create(name: "Daily necessities/Life miscellaneous goods/Travel")
others_6 = others.children.create(name: "antique/collection")
others_7 = others.children.create(name: "stationery/Office supplies")
others_8 = others.children.create(name: "Office work/Store supplies")
others_9 = others.children.create(name: "Other")

others_1.children.create([{name: "all"}])
others_2.children.create([{name: "Pet food"},{name: "Dog supplies"},{name: "Cat supplies"},{name: "Fish supplies/Aquatic plants"},{name: "Small animal supplies"},{name: "reptiles/Amphibian supplies"},{name: "Basket/Ori"},{name: "Bird supplies"},{name: "Insect supplies"},{name: "Other"}])
others_3.children.create([{name: "Confectionery"},{name: "Rice"},{name: "Vegetables"},{name: "fruit"},{name: "seasoning"},{name: "seafood(processed food)"},{name: "meat(processed food)"},{name: "Other processed food"},{name: "Other"}])
others_4.children.create([{name: "coffee"},{name: "Soft drink"},{name: "Mineral water"},{name: "tea"},{name: "whisky"},{name: "wine"},{name: "Brandy"},{name: "Shochu"},{name: "Sake"},{name: "Beer, low-malt beer"},{name: "Other"}])
others_5.children.create([{name: "towel/Bath products"},{name: "Daily necessities/Life miscellaneous goods"},{name: "detergent/Softener"},{name: "Travel goods"},{name: "Disaster prevention related goods"},{name: "Other"}])
others_6.children.create([{name: "Miscellaneous goods"},{name: "Craft"},{name: "furniture"},{name: "Printed matter"},{name: "Other"}])
others_7.children.create([{name: "Writing implements"},{name: "Note/Notepad"},{name: "tape/マスキングtape"},{name: "calendar/Schedule"},{name: "album/scrap"},{name: "File/binder"},{name: "Scissors/cutter"},{name: "Card holder/Business card management"},{name: "Seaweed/Stapler"},{name: "Other"}])
others_8.children.create([{name: "Office supplies in general"},{name: "Office furniture"},{name: "Store supplies"},{name: "OA equipment"},{name: "wrapping/Packaging"},{name: "Other"}])
others_9.children.create([{name: "all"}])

Referenced articles

About ancestry How to use ancestry It was too convenient to use ancestry in multi-level categories Multi-layer category management using ancestry [gem]

Recommended Posts

How to create hierarchical category data using ancestry
[Rails] How to handle data using enum
[Rails] How to create a graph using lazy_high_charts
How to create docker-compose
How to create a data URI (base64) in Java
How to create an application
How to create a method
How to authorize using graphql-ruby
How to use Spring Data JDBC
[Java] How to create a folder
How to build CloudStack using Docker
How to create a jar file or war file using the jar command
How to delete only specific data from data created using Form object
How to execute a contract using web3j
How to sort a List using Comparator
How to create your own headless API using Liferay's REST Builder (Part 3)
How to create your own headless API using Liferay's REST Builder (Part 2)
How to get date data in Ruby
[Rails] How to upload images using Carrierwave
How to create a query using variables in GraphQL [Using Ruby on Rails]
[Java] How to add data to List (add, addAll)
[Java] How to calculate age using LocalDate
[IOS] How to get data from DynamoDB
How to create a Maven repository for 2020
How to create your own headless API using Liferay's REST Builder (Part 4)
[rails] How to create a partial template
[Swift5] How to implement animation using "lottie-ios"
How to implement image posting using rails
How to make asynchronous pagenations using Kaminari
How to create your own headless API using Liferay's REST Builder (Part 1)
How to overwrite Firebase data in Swift
How to insert icons using Font awesome
How to create an Excel form using a template file with Spring MVC
How to create a database for H2 Database anywhere
How to output Excel and PDF using Excella
Summary of how to create JSF self-made tags
How to delete a controller etc. using a command
How to play audio and music using javascript
[Ethereum] How to execute a contract using web3j-Part 2-
How to create pagination for a "kaminari" array
Implement the product category function using ancestry ① (Preparation)
How to implement the breadcrumb function using gretel
How to create a class that inherits class information
How to create multiple pull-down menus with ActiveHash
How to create a theme in Liferay 7 / DXP
How to create search conditions involving multiple models
[Rails] How to upload multiple images using Carrierwave
[1st] How to create a Spring-MVC framework project
How to easily create a pull-down in Rails
How to generate a primary key using @GeneratedValue
Rails6.0 ~ How to create an eco-friendly development environment
[Rails] How to create a Twitter share button
How to link images using FactoryBot Active Storage
How to create member variables with JPA Model
Notes on how to create Burp Suite extensions
[Java] How to operate List using Stream API
How to create an oleore certificate (SSL certificate, self-signed certificate)
How to deploy
How to clear all data in a particular table
How to create a Java environment in just 3 seconds
[Rails] How to create a signed URL for CloudFront