Class: RubyCms::Admin::VisitorErrorsController

Inherits:
BaseController show all
Includes:
RubyCms::AdminPagination, RubyCms::AdminTurboTable
Defined in:
app/controllers/ruby_cms/admin/visitor_errors_controller.rb

Constant Summary

Constants included from RubyCms::AdminPagination

RubyCms::AdminPagination::DEFAULT_MAX_PER_PAGE, RubyCms::AdminPagination::DEFAULT_MIN_PER_PAGE

Instance Method Summary collapse

Methods included from RubyCms::AdminTurboTable

#turbo_frame_id, #turbo_frame_request?, #turbo_redirect_to, #turbo_render_index, #turbo_stream_replace_table, #turbo_stream_request?, #turbo_stream_update_table

Methods included from RubyCms::AdminPagination

#paginate_collection, #set_pagination_vars

Instance Method Details

#bulk_deleteObject



32
33
34
35
36
37
# File 'app/controllers/ruby_cms/admin/visitor_errors_controller.rb', line 32

def bulk_delete
  ids = Array(params[:item_ids]).filter_map(&:to_i)
  count = RubyCms::VisitorError.where(id: ids).destroy_all.size
  redirect_to ruby_cms_admin_visitor_errors_path,
              notice: t("ruby_cms.admin.visitor_errors.bulk_deleted", count:)
end

#bulk_mark_as_resolvedObject



39
40
41
42
43
44
# File 'app/controllers/ruby_cms/admin/visitor_errors_controller.rb', line 39

def bulk_mark_as_resolved
  ids = Array(params[:item_ids]).filter_map(&:to_i)
  count = mark_visitor_errors_resolved(ids)
  redirect_to ruby_cms_admin_visitor_errors_path,
              notice: t("ruby_cms.admin.visitor_errors.bulk_resolved", count:)
end

#indexObject



15
16
17
18
19
20
21
22
# File 'app/controllers/ruby_cms/admin/visitor_errors_controller.rb', line 15

def index
  scope = RubyCms::VisitorError.recent
  scope = scope.where(resolved: params[:resolved] == "true") if params[:resolved].present?
  scope = apply_search_filter(scope)
  scope = apply_error_type_filter(scope)
  @visitor_errors = set_pagination_vars(scope)
  render_index
end

#resolveObject



26
27
28
29
30
# File 'app/controllers/ruby_cms/admin/visitor_errors_controller.rb', line 26

def resolve
  @visitor_error.update!(resolved: true)
  redirect_to ruby_cms_admin_visitor_errors_path,
              notice: t("ruby_cms.admin.visitor_errors.resolved")
end

#showObject



24
# File 'app/controllers/ruby_cms/admin/visitor_errors_controller.rb', line 24

def show; end