Class: Lightrail::Models::Errors::Errors

Inherits:
ActiveModel::Errors
  • Object
show all
Defined in:
lib/lightrail/models/errors.rb

Instance Method Summary collapse

Instance Method Details

#as_json(options = nil) ⇒ Object

Only show one message per error key.



12
13
14
15
16
17
# File 'lib/lightrail/models/errors.rb', line 12

def as_json(options=nil)
  hash   = ActiveSupport::OrderedHash.new
  target = @messages || self
  target.each_key { |k| hash[k] = target[k][0] }
  hash
end