Sha256: c00ab8a45c73789ab747b6ed0a3ba6771a600295eb0e6c523f589cf3eabacf5d

Contents?: true

Size: 730 Bytes

Versions: 8

Compression:

Stored size: 730 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|
            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

8 entries across 8 versions & 1 rubygems

Version Path
klastera-1.2.4.2 lib/tasks/klastera_tasks.rake
klastera-1.2.4.1 lib/tasks/klastera_tasks.rake
klastera-1.2.4 lib/tasks/klastera_tasks.rake
klastera-1.2.3.2 lib/tasks/klastera_tasks.rake
klastera-1.2.3 lib/tasks/klastera_tasks.rake
klastera-1.2.2 lib/tasks/klastera_tasks.rake
klastera-1.2.1 lib/tasks/klastera_tasks.rake
klastera-1.2.0 lib/tasks/klastera_tasks.rake