Skip to content

Instantly share code, notes, and snippets.

@ericcf
Created June 22, 2011 15:20
Show Gist options
  • Save ericcf/1040320 to your computer and use it in GitHub Desktop.
Save ericcf/1040320 to your computer and use it in GitHub Desktop.
example serialization customization
class Ingredient < ActiveRecord::Base
def as_json(options = {})
super(options.merge(
:only => [:id, :name],
:methods => [:time_to_harvest],
:include => {
:substitutes => { :only => [:name] }
}
))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment