listpush/lib/tasks/localeze_categories.rake

16 lines
506 B
Ruby
Raw Normal View History

2014-02-13 20:44:56 +00:00
namespace :localeze do
desc "Update and Get new LocalezeCategories"
task :import => :environment do
before = LocalezeCategory.count
categories = LocalezeClient.new.categories
ActiveRecord::Base.transaction do
categories.each do |cat|
category = LocalezeCategory.where(name: cat).first_or_create!
end
if before < LocalezeCategory.count
puts "Imported #{LocalezeCategory.count - before} categories."
end
end
end
end