Exception: ActiveAdmin::DatabaseHitDuringLoad

Inherits:
ErrorLoading show all
Defined in:
lib/active_admin/error.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ErrorLoading

#find_cause

Constructor Details

#initialize(exception) ⇒ DatabaseHitDuringLoad

Returns a new instance of DatabaseHitDuringLoad.



33
34
35
36
37
38
39
40
41
# File 'lib/active_admin/error.rb', line 33

def initialize(exception)
  file, line = find_cause(:app, exception.backtrace)

  super "Your file, #{file} (line #{line}), caused a database error while Active Admin was loading. This " +
        "is most common when your database is missing or doesn't have the latest migrations applied. To " +
        "prevent this error, move the code to a place where it will only be run when a page is rendered. " +
        "One solution can be, to wrap the query in a Proc. " +
        "Original error message: #{exception.message}"
end

Class Method Details

.captureObject



43
44
45
46
47
# File 'lib/active_admin/error.rb', line 43

def self.capture
  yield
rescue *database_error_classes => exception
  raise new exception
end

.database_error_classesObject



49
50
51
# File 'lib/active_admin/error.rb', line 49

def self.database_error_classes
  @classes ||= []
end