Created
March 4, 2012 21:56
-
-
Save vsavkin/1974986 to your computer and use it in GitHub Desktop.
PersonJsonSerializer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@vsavkin It seems like the logic here is flipped. If there are errors present, don't you want to returns the error messages?