Class: Securial::ApplicationController
- Inherits:
-
ActionController::API
- Object
- ActionController::API
- Securial::ApplicationController
- Defined in:
- app/controllers/securial/application_controller.rb
Overview
ApplicationController
This is the base controller for the Securial engine, inheriting from ActionController::API. and provides common functionality for all Securial controllers, including:
- Custom view path configuration
- Common exception handling for API responses
- Standardized error rendering
All other controllers in the Securial engine inherit from this controller to ensure consistent behavior across the API.
Direct Known Subclasses
AccountsController, PasswordsController, RoleAssignmentsController, RolesController, SessionsController, StatusController, UsersController
Instance Method Summary collapse
-
#render_400(exception) ⇒ void
private
Renders a standardized 400 Bad Request JSON response.
-
#render_404 ⇒ void
private
Renders a standardized 404 Not Found JSON response.
Instance Method Details
#render_400(exception) ⇒ void (private)
This method returns an undefined value.
Renders a standardized 400 Bad Request JSON response.
Called automatically when an ActionController::ParameterMissing exception is raised, providing the client with information about the missing parameter.
43 44 45 46 47 48 |
# File 'app/controllers/securial/application_controller.rb', line 43 def render_400(exception) render status: :bad_request, json: { errors: [exception.], instructions: "Please ensure all required parameters are provided and formatted correctly.", } end |
#render_404 ⇒ void (private)
This method returns an undefined value.
Renders a standardized 404 Not Found JSON response.
Called automatically when an ActiveRecord::RecordNotFound exception is raised, ensuring consistent error responses across the API.
29 30 31 32 33 34 |
# File 'app/controllers/securial/application_controller.rb', line 29 def render_404 render status: :not_found, json: { errors: ["Record not found"], instructions: "Please check the requested resource and try again.", } end |