small medium large xlarge

Generic-user-small
26 May 2009, 19:38
Ben Young (1 post)

I wanted a slightly more generic to_xml solution for Recipe #66 so I came up with this:

  def to_xml(options = {})
    options[:only] = self.class.column_names - self.class.attr_protected.to_a
    super(options)
  end

This will only work if you are defining protected attributes but, I’ll leave the accessible case as an exercise for the reader ;)

You must be logged in to comment