Sha256: faced444be6884b217ce1ae50f10c4662f5fe6b1192ccc5b416dcf816fae6b9a
Contents?: true
Size: 899 Bytes
Versions: 22
Compression:
Stored size: 899 Bytes
Contents
# desc "Explaining what the task does" # task :klastera do # # Task goes here # end namespace :klastera do namespace :seed do desc "Move cluster_id to cluster_entities" task :cluster_entities, [:entity] => :environment do |task,args| begin klass = args.entity.constantize ActiveRecord::Base.transaction do klass.where.not(cluster_id: nil).each do |entity| if entity.cluster.blank? puts "Cluster ID #{entity.cluster_id} was not found!" puts "skip..." next end Klastera::ClusterEntity.create(entity: entity, cluster: entity.cluster) end end rescue NameError => ne puts "NameError Exception: #{ne}" rescue ActiveRecord::StatementInvalid => asi puts "ActiveRecord::StatementInvalid Exception #{asi}" end end end end
Version data entries
22 entries across 22 versions & 1 rubygems