Module: Restful::Jsonapi::SerializableErrors
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/restful/jsonapi/serializable_errors.rb
Instance Method Summary collapse
Instance Method Details
#serializable_errors(object) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/restful/jsonapi/serializable_errors.rb', line 6 def serializable_errors(object) prefix = object.class.to_s.demodulize.underscore errors = object.errors.to_hash.each_with_object([]) do |(k, v), array| v.each do |msg| array.push(id: "#{prefix}.#{k}", title: msg) end end { errors: errors } end |