From: "Älphä Blüë" Date: 2009-07-18T13:00:14+09:00 Subject: Re: Creation of Table Data From Rake Rob, Thanks mate. I wanted to follow-up over here as well since you really did a great job helping me out with this issue. Here's what I ended up doing: Okay, after testing and testing, I finally managed to get it all to work. However, I'm sure my way is very clumsily implemented but it was the only way I understood how to read the values and place them into the table. I called the following from Rake: update_tsos_offense.table_update(TsosOffense, stats) # model, # array And in the model for table_update I did: def table_update(model, array) if model.compiled_this_week.find(:all).empty? puts "Updating #{model} for the following teams:" 120.times do |i| team = Team.find(i + 1) values = {:compiled_on => Date.today.strftime('%Y-%m-%d')} values[:team_id] = i + 1 values[:totoff] = array[i + 1][:totoff] values[:rushoff] = array[i + 1][:rushoff] values[:passoff] = array[i + 1][:passoff] values[:scoroff] = array[i + 1][:scoroff] values[:rzonoff] = array[i + 1][:rzonoff] values[:fumlost] = array[i + 1][:fumlost] values[:passhint] = array[i + 1][:passhint] values[:tolost] = array[i + 1][:tolost] values[:sacksall] = array[i + 1][:sacksall] values[:tackflossall] = array[i + 1][:tackflossall] values[:passeff] = array[i + 1][:passeff] values[:firdwns] = array[i + 1][:firdwns] values[:thrdwncon] = array[i + 1][:thrdwncon] values[:fthdwncon] = array[i + 1][:fthdwncon] model.create values puts "#{team.name} values are being saved." end else # data is already populated for the week so don't update puts "Current Week's Ratings are Already updated!" end end I had to add 1 because the i count started at 0. I also couldn't use the constant or iterate using each or each_with_index because one, I couldn't get it to sort. This way does work though and so I'm happy that it at least is functioning. Although, I'm sure it can use some cleanup. Please let me know if anyone sees a way for me to make this code a bit cleaner. Many thanks Rob. -- Posted via http://www.ruby-forum.com/.