Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

PersonJsonSerializer

View ddd_example1_2.rb
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.