Module: Respect::Rails::ControllerHelper::ClassMethods
- Defined in:
- lib/respect/rails/controller_helper.rb
Instance Method Summary (collapse)
-
- (Object) def_action_schema(action_name, &block)
FIXME(Nicolas Despres): Document me.
-
- (Object) rescue_from_request_validation_error
Install a handler for RequestValidationError.
Instance Method Details
- (Object) def_action_schema(action_name, &block)
FIXME(Nicolas Despres): Document me.
33 34 35 36 37 |
# File 'lib/respect/rails/controller_helper.rb', line 33 def def_action_schema(action_name, &block) define_method("#{action_name}_schema") do Respect::Rails::ActionSchema.define(self, action_name, &block) end end |
- (Object) rescue_from_request_validation_error
Install a handler for RequestValidationError. It provides a more specific error report than the default exception handler in development. For instance you get the context of where the error happened in the JSON document.
Example:
# In your ApplicationController class. rescue_from_request_valiation_error if Rails.env.development?
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/respect/rails/controller_helper.rb', line 18 def rescue_from_request_validation_error rescue_from Respect::Rails::RequestValidationError do |exception| respond_to do |format| format.html do @error = exception render template: "respect/rails/request_validation_exception", layout: false, status: :internal_server_error end format.json do render json: exception.to_json, status: :internal_server_error end end end end |