Skip to content

Instantly share code, notes, and snippets.

@rramsden
Created May 30, 2011 16:38
Show Gist options
  • Select an option

  • Save rramsden/999129 to your computer and use it in GitHub Desktop.

Select an option

Save rramsden/999129 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
puts "looking at #{assoc.name}"
if #{assoc.name}.first.respond_to?(:to_backup)
puts "#{assoc.name} responded"
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