dimanche 31 mai 2015

has_ancestry/ assigning hierarchy to existing table

I have a database that is imported from a CSV file and I would like to assign hierarchy based on the assembly level below. not sure which approach to take. I can write if statements but it will be very long. sorry I am new to this, and I don't know where to begin. any help is much appreciated.

assembly_level         assembly_tree           description      uniq_id
0                      zero level               "zero level"    d9s64
1                       level one assembly      "level one"     c9633
2                        level two assembly     "level two"     11197
3                         level three assembly  "level three"   e271f
4                          level four assembly  "level four"    552da
4                          level four assembly  "level four"    4568a
3                         level three assembly  "level three"   b72bd

edit

who can I assign assembly_level to Parent_id during import?

@item = Item.new(:assembly_level=> params[:parent_id])

Aucun commentaire:

Enregistrer un commentaire