Skip to content

Instantly share code, notes, and snippets.

@uhhuhyeah
Created September 26, 2010 15:28
Show Gist options
  • Save uhhuhyeah/598023 to your computer and use it in GitHub Desktop.
Save uhhuhyeah/598023 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
def to_xml(options={})
options[:only] = [:id, :name, :other_attr]
super(options)
end
end
@uhhuhyeah
Copy link
Author

Instead of writing an xml or json view to only show the attrs I want to show, I can override the to_xml method and make a list of the attrs to show.

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