I am trying to execute multiple rake tasks in a single task. All of the rake tasks are used to update the columns of respective tables. For example if health_post_id >100000 Delete that record
Now i need to pass 100000 as an argument through the command line .But I am not able to figure that out Here is the code
if Rails.env.development? or Rails.env.test?
namespace :clear_data do
desc 'clear time slots'
task :clear_time_slots => :environment do
TimeSlot.where('health_post_id > ?', p).each do |time_slots|
time_slots.destroy
end
end
desc "Clean the Practices table"
task :clear_practice_records => :environment do
Practice.where('health_post_id > ?', p).each do |practices|
practices.destroy
end
end
desc "clean database"
task :clear_database => :environment do |p|
Rake::Task['clear_data:clear_practice_records'].execute
Rake::Task['clear_data:clear_time_slots'].execute
end
end
end