I want to use this code to run rake task:
task :backup_and_delete_old_data => :environment do
if defined?(Rails)
require Rails.root + '/config/boot'
else
require '../../../config/boot'
end
require Rails.root + '/config/environment'
factory_backup.each do |factory_data|
puts ">> Backup and delete old #{factory_data.to_s.pluralize.humanize} data..."
factory_data.factory_backup(backup_and_delete_old_data)
end
end
But when I run the rake task I get error:
TypeError: no implicit conversion of Pathname into String
for this line:
require Rails.root + '/config/boot'
Do you know how I can fix this issue?
Have you tried to do Rails.root.to_s?
I guess the problem is that Rails.root is a PathName, not a String, as you can see on the below picture.

You can easily concatenate with the + operator if you cast the Rails.root to String. Please check the below picture.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With