Class: Chronicle::ResourceController
- Inherits:
-
ApplicationController
- Object
- ActionController::API
- ApplicationController
- Chronicle::ResourceController
- Includes:
- Filterable, Pagination
- Defined in:
- app/controllers/chronicle/resource_controller.rb
Direct Known Subclasses
ApiLogsController, ApiRoutesController, ErrorGroupsController, ErrorLogsController
Constant Summary
Constants included from Pagination
Pagination::DEFAULT_LIMIT, Pagination::MAX_LIMIT
Instance Method Summary collapse
Methods included from Filterable
Methods included from Pagination
Instance Method Details
#index ⇒ Object
8 9 10 11 12 13 |
# File 'app/controllers/chronicle/resource_controller.rb', line 8 def index query = build_query(model, filter_definition: filter_definition, filters: params[:filters], date_column: date_column) query = query.includes(eager_load_associations) if eager_load_associations.any? render json: paginate(query), status: :ok end |
#show ⇒ Object
15 16 17 18 19 20 21 |
# File 'app/controllers/chronicle/resource_controller.rb', line 15 def show record = model.find_by(id: params[:id]) raise NotFoundError, 'Record not found' unless record data = record.respond_to?(:get_hash) ? record.get_hash : record.attributes render json: data, status: :ok end |