Skip to content

Instantly share code, notes, and snippets.

@milandobrota
Created August 18, 2009 18:40
Show Gist options
  • Save milandobrota/169874 to your computer and use it in GitHub Desktop.
Save milandobrota/169874 to your computer and use it in GitHub Desktop.
item.categories.each do |rss_category|
rss_category.strip.split(',').each do |rss_category_split|
if rss_category_split
# Create the new category is necessary
category = Category.find_by_name(rss_category_split.strip)
if !category
# Try to find a merge category before creating a new category.x
categoryMerge = CategoryMerge.find_by_merge_src(rss_category_split.strip)
if categoryMerge
category = Category.find_by_id(categoryMerge.merge_target)
end
if !category
category = Category.new
category.name = rss_category_split.strip
end
end
new_feed_item.categories << category
end
end
end #each_with_index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment