public
Last active

PersonJsonSerializer

  • Download Gist
ddd_example1_2.rb
Ruby
1 2 3 4 5 6 7 8 9
module PersonJsonSerializer
def self.as_json person
if person.errors.present?
person.as_json(:root => "root-attrs")
else
{:errors => person.errors.full_messages}
end
end
end

@vsavkin It seems like the logic here is flipped. If there are errors present, don't you want to returns the error messages?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.