Adam @ Heroku
a tornado of razorblades

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
Hierarchy: previous, next

Comments

There are 0 comments on this post. Post yours →

Post a comment

Required fields in bold.