Class: Multitenant::Mysql::DB
- Inherits:
-
Object
- Object
- Multitenant::Mysql::DB
- Defined in:
- lib/multitenant-mysql/db.rb
Class Method Summary collapse
- .configs ⇒ Object
- .configs=(configs) ⇒ Object
- .connection ⇒ Object
- .establish_connection_for(tenant_name) ⇒ Object
Class Method Details
.configs ⇒ Object
5 6 7 |
# File 'lib/multitenant-mysql/db.rb', line 5 def configs @configs ||= Rails.configuration.database_configuration[Rails.env] end |
.configs=(configs) ⇒ Object
9 10 11 |
# File 'lib/multitenant-mysql/db.rb', line 9 def configs=(configs) @configs = configs end |
.connection ⇒ Object
19 20 21 |
# File 'lib/multitenant-mysql/db.rb', line 19 def connection ActiveRecord::Base.connection end |
.establish_connection_for(tenant_name) ⇒ Object
13 14 15 16 17 |
# File 'lib/multitenant-mysql/db.rb', line 13 def establish_connection_for tenant_name config = configs config['username'] = tenant_name.blank? ? 'root' : tenant_name ActiveRecord::Base.establish_connection(config) end |