Module: DatabaseConnection
- Defined in:
- lib/config/database_connection.rb
Class Method Summary collapse
Class Method Details
.connect!(env) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/config/database_connection.rb', line 6 def self.connect!(env) # Ref https://github.com/puma/puma#clustered-mode ActiveSupport.on_load(:active_record) do ::ActiveRecord::Base.connection_pool.disconnect! if ::ActiveRecord::Base.connected? ::ActiveRecord::Base.configurations = YAML.safe_load(ERB.new(File.read("db/config.yml")).result, [], [], true) || {} config = ::ActiveRecord::Base.configurations[env.to_s] ::ActiveRecord::Base.establish_connection(config) end end |