Module: ExceptionLoggableControllerMixin

Defined in:
lib/exception_loggable_controller_mixin.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.custom_view_pathsObject

Returns the value of attribute custom_view_paths.



4
5
6
# File 'lib/exception_loggable_controller_mixin.rb', line 4

def custom_view_paths
  @custom_view_paths
end

Class Method Details

.included(app) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/exception_loggable_controller_mixin.rb', line 6

def included(app)
  app.module_eval do
    cattr_accessor :application_name
    layout nil
    self.view_paths = ExceptionLoggableControllerMixin.custom_view_paths
  end
end

Instance Method Details

#destroyObject



58
59
60
61
# File 'lib/exception_loggable_controller_mixin.rb', line 58

def destroy
  @exception = LoggedException.find params[:id]
  @exception.destroy
end

#destroy_allObject



63
64
65
66
# File 'lib/exception_loggable_controller_mixin.rb', line 63

def destroy_all
  LoggedException.delete_all ['id in (?)', params[:ids]] unless params[:ids].blank?
  query
end

#indexObject



15
16
17
18
19
# File 'lib/exception_loggable_controller_mixin.rb', line 15

def index
  @exception_names    = LoggedException.find_exception_class_names
  @controller_actions = LoggedException.find_exception_controllers_and_actions
  query
end

#queryObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/exception_loggable_controller_mixin.rb', line 21

def query
  conditions = []
  parameters = []
  unless params[:id].blank?
    conditions << 'id = ?'
    parameters << params[:id]
  end
  unless params[:query].blank?
    conditions << 'message LIKE ?'
    parameters << "%#{params[:query]}%"
  end
  unless params[:date_ranges_filter].blank?
    conditions << 'created_at >= ?'
    parameters << params[:date_ranges_filter].to_f.days.ago.utc
  end
  unless params[:exception_names_filter].blank?
    conditions << 'exception_class = ?'
    parameters << params[:exception_names_filter]
  end
  unless params[:controller_actions_filter].blank?
    conditions << 'controller_name = ? AND action_name = ?'
    parameters += params[:controller_actions_filter].split('/').collect(&:downcase)
  end
  @exceptions = LoggedException.paginate :order => 'created_at desc', :per_page => 30, 
    :conditions => conditions.empty? ? nil : parameters.unshift(conditions * ' and '), :page => params[:page]
  
  respond_to do |format|
    format.html { redirect_to :action => 'index' unless action_name == 'index' }
    format.js   { render :action => 'query.rjs'  }
    format.rss  { render :action => 'query.rxml' }
  end
end

#showObject



54
55
56
# File 'lib/exception_loggable_controller_mixin.rb', line 54

def show
  @exception = LoggedException.find params[:id]
end