Module: Incline::Extensions::ApplicationConfiguration
- Defined in:
- lib/incline/extensions/application_configuration.rb
Overview
Creates a default database configuration to use when config/database.yml is not present.
Class Method Summary collapse
-
.included(base) ⇒ Object
Override the
database_configuration
method to return something in development mode if theconfig/database.yml
file is missing.
Class Method Details
.included(base) ⇒ Object
Override the database_configuration
method to return something in development mode if the config/database.yml
file is missing.
A warning will be logged if the default configuration is used. In production mode, an exception will be bubbled up.
The default configuration for test and development environments is to use a sqlite database in the db folder using the environment name (eg - db/development.sqlite).
The primary purpose of this is to allow rake
and rails
actions that may not depend on the database configuration or may actually be used to generate the configuration file.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/incline/extensions/application_configuration.rb', line 20 def self.included(base) #:nodoc: base.class_eval do alias :incline_appconfig_original_database_configuration :database_configuration def database_configuration begin incline_appconfig_original_database_configuration rescue raise unless $!.inspect.include?('No such file -') && (!Rails.env.production?) default = { 'adapter' => 'sqlite3', 'pool' => 5, 'timeout' => 5000 } Incline::Log::warn "Providing default database configuration for #{Rails.env} environment." { 'test' => default.merge('database' => 'db/test.sqlite'), 'development' => default.merge('database' => 'db/development.sqlite') } end end end end |