Module: Desponders::ErrorResponder
- Defined in:
- lib/desponders/error_responder.rb
Instance Method Summary collapse
- #lookup_message ⇒ Object
-
#to_format ⇒ Object
If it isn’t a get request and the response model has errors it automatically renders json with errors.
Instance Method Details
#lookup_message ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/desponders/error_responder.rb', line 15 def action = controller.action_name lookup = ['errors', action].join('.').to_sym = { resource_name: resource.class.model_name.human } I18n.t(lookup, ) end |
#to_format ⇒ Object
If it isn’t a get request and the response model has errors it automatically renders json with errors
5 6 7 8 9 10 11 12 13 |
# File 'lib/desponders/error_responder.rb', line 5 def to_format if has_errors? controller.render json: { message: , errors: resource.errors }, status: :unprocessable_entity else super end end |