Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
PersonJsonSerializer
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
@tundal45

This comment has been minimized.

Show comment Hide comment
@tundal45

tundal45 Jan 28, 2014

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment