|
|
|
|
@ -66,13 +66,13 @@ class Cdao::Subject < Cdao::Base
|
|
|
|
|
sub5_name = names[5] |
|
|
|
|
sub6_name = names[6] |
|
|
|
|
|
|
|
|
|
root = Cdao::Subject.find_or_initialize_by(name: root_name, ancestry: nil) if root_name.present? |
|
|
|
|
sub1 = root.children.find_or_initialize_by(name: sub1_name) if root.present? && sub1_name.present? |
|
|
|
|
sub2 = sub1.children.find_or_initialize_by(name: sub2_name) if sub1.present? && sub2_name.present? |
|
|
|
|
sub3 = sub2.children.find_or_initialize_by(name: sub3_name) if sub2.present? && sub3_name.present? |
|
|
|
|
sub4 = sub3.children.find_or_initialize_by(name: sub4_name) if sub3.present? && sub4_name.present? |
|
|
|
|
sub5 = sub4.children.find_or_initialize_by(name: sub5_name) if sub4.present? && sub5_name.present? |
|
|
|
|
sub6 = sub5.children.find_or_initialize_by(name: sub6_name) if sub5.present? && sub6_name.present? |
|
|
|
|
root = Cdao::Subject.find_or_create_by(name: root_name, ancestry: nil) if root_name.present? |
|
|
|
|
sub1 = root.children.find_or_create_by(name: sub1_name) if root.present? && sub1_name.present? |
|
|
|
|
sub2 = sub1.children.find_or_create_by(name: sub2_name) if sub1.present? && sub2_name.present? |
|
|
|
|
sub3 = sub2.children.find_or_create_by(name: sub3_name) if sub2.present? && sub3_name.present? |
|
|
|
|
sub4 = sub3.children.find_or_create_by(name: sub4_name) if sub3.present? && sub4_name.present? |
|
|
|
|
sub5 = sub4.children.find_or_create_by(name: sub5_name) if sub4.present? && sub5_name.present? |
|
|
|
|
sub6 = sub5.children.find_or_create_by(name: sub6_name) if sub5.present? && sub6_name.present? |
|
|
|
|
|
|
|
|
|
root.descendants.each { |a| a.library_ids = [Cdao::Library.find_by(key: "JurisprudenceEncyclopedia").try(:id)] } if root.present? |
|
|
|
|
end |
|
|
|
|
|