to_xml

activerecord rest

Sun Mar 16 19:57:00 -0700 2008

When serving up an ActiveRecord as resource, you can use options like :only and :except to to_xml. But in most cases, you want the same fields served every time - on create, update, and get. So put the options into the class itself:

def to_xml(options={})
  options[:only] ||= [ :name, :width, :height, :created_at ]
  super
end