Class: ErrorLens::ErrorsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ErrorLens::ErrorsController
- Defined in:
- app/controllers/error_lens/errors_controller.rb
Constant Summary collapse
- GROUPS_PER_PAGE =
25- OCCURRENCES_PER_PAGE =
10
Instance Method Summary collapse
Instance Method Details
#destroy ⇒ Object
42 43 44 45 46 |
# File 'app/controllers/error_lens/errors_controller.rb', line 42 def destroy @group = ErrorLens::ErrorGroup.find(params[:id]) @group.destroy! redirect_to errors_path, notice: "Error deleted." end |
#index ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/error_lens/errors_controller.rb', line 6 def index @groups = ErrorLens::ErrorGroup.recent @groups = @groups.filter_by(params[:q]) if params[:q].present? @groups = @groups.by_env(params[:environment]) if params[:environment].present? @groups = params[:resolved] == "true" ? @groups.resolved : @groups.unresolved @total = @groups.count @page = [params[:page].to_i, 1].max @total_pages = (@total / GROUPS_PER_PAGE.to_f).ceil @groups = @groups.limit(GROUPS_PER_PAGE).offset((@page - 1) * GROUPS_PER_PAGE) end |
#resolve ⇒ Object
30 31 32 33 34 |
# File 'app/controllers/error_lens/errors_controller.rb', line 30 def resolve @group = ErrorLens::ErrorGroup.find(params[:id]) @group.resolve! redirect_to errors_path, notice: "Error marked as resolved." end |
#show ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/error_lens/errors_controller.rb', line 19 def show @group = ErrorLens::ErrorGroup.find(params[:id]) @total = @group.occurrences.count @page = [params[:page].to_i, 1].max @total_pages = (@total / OCCURRENCES_PER_PAGE.to_f).ceil @occurrences = @group.occurrences .recent .limit(OCCURRENCES_PER_PAGE) .offset((@page - 1) * OCCURRENCES_PER_PAGE) end |
#unresolve ⇒ Object
36 37 38 39 40 |
# File 'app/controllers/error_lens/errors_controller.rb', line 36 def unresolve @group = ErrorLens::ErrorGroup.find(params[:id]) @group.unresolve! redirect_to error_path(@group), notice: "Error reopened." end |