Module: Mihari::Mixins::Database

Included in:
Commands::Database, Commands::Searcher, Mihari::Middleware::ConnectionAdapter
Defined in:
lib/mihari/mixins/database.rb

Instance Method Summary collapse

Instance Method Details

#with_db_connectionObject



6
7
8
9
10
11
12
13
# File 'lib/mihari/mixins/database.rb', line 6

def with_db_connection
  Mihari::Database.connect
  yield
rescue ActiveRecord::StatementInvalid
  Mihari.logger.error("You haven't finished the DB migration! Please run 'mihari db migrate'.")
ensure
  Mihari::Database.close
end