Created
October 4, 2017 14:24
-
-
Save timrwilliams/7e61a2159111646c95ceae75df01c812 to your computer and use it in GitHub Desktop.
Choose an Apartment Tenant on start of IRB/Rails console (works on Heroku)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "What tenant do you require? " | |
tenant_names = Apartment.tenant_names | |
tenant_names.each_with_index do | tenant, index | | |
puts "#{index}: #{tenant}" | |
end | |
tenant_index = gets.chomp.to_i | |
tenant = tenant_names[tenant_index] | |
tenant = "public" if tenant.blank? | |
Apartment::Tenant.switch!(tenant) | |
puts "Current tenant: #{Apartment::Tenant.current}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Designed to ensure you consciously choose what Apartment Tenant to work on when using the Rails console.
heroku run rails c -a my-application
you will be prompted to select a tenant on console startup: