As a quick and dirty test,
puts "Updating Current Data in #{model} for the following teams:"
x = 0
y = model.compiled_this_week.find(:all)
parser_object.rows.each do |row|
team = Team.find_by_name(row[1])
values = {:compiled_on => Date.today.strftime('%Y-%m-%d')}
constant.each_with_index do |field, i|
if row[i] == row[1]
values[field] = team.id
else
values[field] = row[i]
end
end
# List each team we update
puts team.name + " ID = " + team.id.to_s
model.update(y[x], values)
x += 1
end
This portion of the update process works fine using this. However, I
had to call model find again and iterate over the ids in no particular
order. I don't mind iterating over the ids without a precise order
because the data being overwritten is being overwritten for the current
week against 120 rows of data. So, it doesn't matter if they are in a
different order, so long as the data for each row is exact, which by
this quick and dirty test is.
I'll have to find a cleaner way of implementing it though.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---