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

Attributes inherited from AdapterError

#connection_pool

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StatementInvalid

#set_query

Constructor Details

#initialize(message = nil, connection_pool: nil) ⇒ NoDatabaseError

Returns a new instance of NoDatabaseError.



322
323
324
# File 'lib/active_record/errors.rb', line 322

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

Class Method Details

.db_error(db_name) ⇒ Object



327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/active_record/errors.rb', line 327

def db_error(db_name)
  NoDatabaseError.new(<<~MSG)
    We could not find your database: #{db_name}. Available database configurations can be found in config/database.yml.

    To resolve this error:

    - Did you not create the database, or did you delete it? To create the database, run:

        bin/rails db:create

    - Has the database name changed? Verify that config/database.yml contains the correct database name.
  MSG
end