Exception: ActiveRecord::NoDatabaseError

Inherits:
StatementInvalid show all
Includes:
ActiveSupport::ActionableError
Defined in:
lib/active_record/errors.rb

Overview

Raised when a given database does not exist.

Instance Attribute Summary

Attributes inherited from StatementInvalid

#binds, #sql

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil) ⇒ NoDatabaseError

Returns a new instance of NoDatabaseError.



245
246
247
# File 'lib/active_record/errors.rb', line 245

def initialize(message = nil)
  super(message || "Database not found")
end

Class Method Details

.db_error(db_name) ⇒ Object



250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/active_record/errors.rb', line 250

def db_error(db_name)
  NoDatabaseError.new("    We could not find your database: \#{db_name}. Which can be found in the database configuration file located at config/database.yml.\n\n    To resolve this issue:\n\n    - Did you create the database for this app, or delete it? You may need to create your database.\n    - Has the database name changed? Check your database.yml config has the correct database name.\n\n    To create your database, run:\\n\\n        bin/rails db:create\n  MSG\nend\n")