What is the easiest way to dump a selection of data for someone else
to import? If XML, what is the cleanest way to accomplish this?
As a hobby, I wrote a workout logging program that now has about 2000
users. From time to time, someone asks me to export their workout
records to another application. I finally decided to set up an XML
resource for this. But I don't want to put a lot of effort into it.
Right now, my controller looks like this:
def person_workouts_xml
@person = Person.find(params[:id])
@workouts = @person.workouts
end
My .builder template looks like this:
xml.instruct! :xml, :version=>"1.0"
xml.workouts{
for workout in @workouts
xml.workout(workout.to_xml)
end }
I also tried the builder template like this:
xml.workouts(@workouts.to_xml)
Both methods work, but the output is rather ugly, and I doubt others
will want to slog through it. Should I be using to_xml in combination
with the builder this way? Is there a better, cleaner, simpler way?
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment