Skip to content

Instantly share code, notes, and snippets.

@rramsden
Created May 30, 2011 16:38
Show Gist options
  • Save rramsden/999130 to your computer and use it in GitHub Desktop.
Save rramsden/999130 to your computer and use it in GitHub Desktop.
Website.reflect_on_all_associations( :has_many ).each do | assoc |
instance_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
if #{assoc.name}.first.respond_to?(:to_backup)
xml.#{assoc.name} do
#{assoc.name}.each {|collection| xml << collection.to_backup}
end unless #{assoc.name}.blank?
end
RUBY_EVAL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment