Hi Ryan,
Thanks for this. I was trying to write a custom rake task , say sending email And this has to be run against each tenant schema. I wrote lib/tasks/mailer.rake
desc "send mail for conditions"
task send_email: :environment do
#conditions
puts 'HHHHHHHHHHHHHHHHhh'
end
But this gives me error: undefined method `strip' for :"Run db:migrate for each tenant":Symbol
I have the lib/tasks/multitenant.rake like below
`db_tasks = %w[db:migrate db:migrate:up db:migrate:down db:rollback db:forward]
namespace :multitenant do
db_tasks.each do |task_name|
desc :"Run #{task_name} for each tenant"
task task_name => %w[environment db:load_config] do
Tenant.find_each do |tenant|
puts "Running #{task_name} for tenant#{tenant.id} (#{tenant.subdomain})"
tenant.scope_schema {Rake::Task[task_name].execute}
end
end
end
end
db_tasks.each do |task_name|
Rake::Task[task_name].enhance(["multitenant:#{task_name}"])`
Hi Ryan,
Thanks for this. I was trying to write a custom rake task , say sending email And this has to be run against each tenant schema. I wrote lib/tasks/mailer.rake
desc "send mail for conditions"task send_email: :environment do
#conditions
puts 'HHHHHHHHHHHHHHHHhh'
end
But this gives me error: undefined method `strip' for :"Run db:migrate for each tenant":Symbol
I have the lib/tasks/multitenant.rake like below
`db_tasks = %w[db:migrate db:migrate:up db:migrate:down db:rollback db:forward]
namespace :multitenant do
db_tasks.each do |task_name|
desc :"Run #{task_name} for each tenant"
task task_name => %w[environment db:load_config] do
Tenant.find_each do |tenant|
puts "Running #{task_name} for tenant#{tenant.id} (#{tenant.subdomain})"
tenant.scope_schema {Rake::Task[task_name].execute}
end
end
end
end
db_tasks.each do |task_name|
Rake::Task[task_name].enhance(["multitenant:#{task_name}"])`
Please help
Thanks Ryan for this episode. Yet to watch this. I would like to know whether this work with Ruby1.8.7?