Sha256: 9626c20cb6b11da8d5630cb4a3eb1fc31daeabfb6f2dfc0f32ba76cd8d5b3f1e

Contents?: true

Size: 592 Bytes

Versions: 6

Compression:

Stored size: 592 Bytes

Contents

if defined?(ActiveRecord)
  require 'yaml'
  require 'erb'

  configurations = YAML.safe_load(ERB.new(Grape::App.root.join('config', 'database.yml').read).result) || {}
  if ENV['DATABASE_URL']
    configurations[Grape::App.env.to_s] ||= {}
    configurations[Grape::App.env.to_s]['url'] ||= ENV['DATABASE_URL']
  end
  ActiveRecord::Base.configurations = configurations
  ActiveRecord::Base.establish_connection(Grape::App.env.to_sym)

  Grape::App.middleware.use ActiveRecord::ConnectionAdapters::ConnectionManagement if defined?(ActiveRecord::ConnectionAdapters::ConnectionManagement)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
grape-app-0.11.3 lib/grape/app/initializers/post.rb
grape-app-0.11.2 lib/grape/app/initializers/post.rb
grape-app-0.11.1 lib/grape/app/initializers/post.rb
grape-app-0.11.0 lib/grape/app/initializers/post.rb
grape-app-0.10.1 lib/grape/app/initializers/post.rb
grape-app-0.10.0 lib/grape/app/initializers/post.rb