Skip to content

Instantly share code, notes, and snippets.

@vsavkin
Created March 4, 2012 21:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsavkin/1974986 to your computer and use it in GitHub Desktop.
Save vsavkin/1974986 to your computer and use it in GitHub Desktop.
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
Copy link

@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