Class: SuperSettings::Storage::ActiveRecordStorage::Model

Inherits:
ApplicationRecord
  • Object
show all
Defined in:
lib/super_settings/storage/active_record_storage/models.rb

Class Method Summary collapse

Class Method Details

.available?Boolean

ActiveRecord storage is only available if the connection pool is connected and the table exists.

Returns:



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/super_settings/storage/active_record_storage/models.rb', line 19

def available?
  begin
    # table_exists? will attempt to retrieve a connection from the pool and load the schema_cache
    # which is memoized per connection. If there is no database or connection, it will raise an error.
    table_exists?
  rescue ActiveRecord::NoDatabaseError, ActiveRecord::ConnectionNotEstablished
    # Ignore errors so the application doesn't break if the database is not available.
    # Otherwise things like build processes can fail.
    false
  end
end