Skip to content

Instantly share code, notes, and snippets.

@wemrekurt
Created April 3, 2019 21:06
Show Gist options
  • Select an option

  • Save wemrekurt/a6c44a7457b5ce9e635eb876b1771370 to your computer and use it in GitHub Desktop.

Select an option

Save wemrekurt/a6c44a7457b5ce9e635eb876b1771370 to your computer and use it in GitHub Desktop.
def create_import(curr, files)
Category.create(curr)
subs = files.select { |i| i['parent_id'] == curr['id'] }
subs.each { |cat| create_import(cat, files) }
end
def create_features(cat, features)
fets = features.select do |i|
i['category_ids'] == cat.id
end
fets.each { |ft| Feature.create(ft) }
cat.children.each { |c| create_features(c, features) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment