I have created multi-tenant application using Apartment Gem, I want to update all records in each databases but when I am trying to switch database using
Apartment::Tenant.switch!("db_one")
and if database not present then it gives error
Error while connecting to tenant db_one FATAL: database "db_one" does not exist
and if I change another database like db_two then it gives same error
Use block when you are switching database like below:
Apartment::Tenant.switch("db_name") do
# Your Code
end
remove !
from switch
method and use do
and end