Some notes:
rexml/document. I'd use Nokogiri without doubta second thought, but if you preferrexmlbecause it's comes in the standard library, that's ok.Rails.logger.info "all done". I wouldn't mix code with and without parens. I definetely would write them on method signatures.def self.save_races. You may not need it right now, but as a rule of thumb is good that functions/methodmethods return values. Here the races saved races (since the method is calledsave_races).entry_element.elements['Horse'].attributesused a lot of times: useset a local variable.t = {}followed byt = somethinginside a each? That's not good practice, should be written in a different way. If thoseeachjust want to take one element, put afirstor something.The most important point: almost all those
save_xyzmethods contain this pattern:sum = Summary.where(:name => s[:name] ).where(:start_id => s[:start_id]).first if sum Summary.update(sum.id, s) else Summary.create(s) endThat should be abstracted so you canwith a method (in the app, or monkeypatched). You should be able to write something like (or similar, you get the idea):
Summary.create_or_update(attrsattributes, :on_findfind => [:name, :start_id])By the way that's not a fancy abstraction I came up with here, I use it in my projects (since
find_or_create_bymethods from Rails fall short).