Skip to content

Instantly share code, notes, and snippets.

@buren
Created July 11, 2017 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buren/f15370fe87cc53d6ee2446ab57177378 to your computer and use it in GitHub Desktop.
Save buren/f15370fe87cc53d6ee2446ab57177378 to your computer and use it in GitHub Desktop.
sv_lang = Language.find_by(lang_code: :sv)
en_lang = Language.find_by(lang_code: :en)
ar_lang = Language.find_by(lang_code: :ar)
root_industry = nil
result = csv.map do |row|
sv, en, ar = row
is_root_industry = false
if sv.start_with?('__')
sv = sv.gsub(/__/, '')
root_industry = nil
is_root_industry = true
end
industry = Industry.create!(
language: sv_lang,
parent: root_industry
)
industry.set_translation({ name: sv }, sv_lang)
industry.set_translation({ name: en }, en_lang)
industry.set_translation({ name: ar }, ar_lang)
root_industry = industry if is_root_industry
industry
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment