Skip to content

Instantly share code, notes, and snippets.

@benaneesh
Last active December 25, 2015 15:29
Show Gist options
  • Save benaneesh/6998849 to your computer and use it in GitHub Desktop.
Save benaneesh/6998849 to your computer and use it in GitHub Desktop.
color_list = Tags::Color.all.map {|n| n.name}
hash = Hash[color_list.map.with_index.to_a]
missing_ids = []
Style.joins(:taggings).find_each do |tags|
id = tags.id
tags.taggings.each do |t|
begin
name = TagValue.find(t.tag_value_id).name
if color_list.include? name
StyleColor.create!(:style_id => id, :color_id => hash[name]+1)
end
rescue
missing_ids << t.tag_value_id
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment