Hi guys/gals, Okay some good news. I'm able to pass the information to the correct model and inspect it. I just don't know how to iterate through this type of array. As it contains a hash setup, I'm not as experienced with this piece. Could someone give me some pointers on how to iterate through this data in my update_table method?
Here's what I have so far: def table_update(model, constant, array) #puts array.inspect if model.compiled_this_week.find(:all).empty? puts "Updating #{model} for the following teams:" array.each do |row| values = {:compiled_on => Date.today.strftime('%Y-%m-%d')} constant.each_with_index do |field, i| values[field] = row[i] end model.create values end else # data is already populated for the week so don't update puts "Current Week's Ratings are Already updated!" end end compiled_this_week is just a scope that checks for between dates and I'm finding out if the table is empty. If it is empty for the specified dates (current week basically) I populate the table with new data.. "constant" refers to a constant I have setup in my environment.rb file which houses the fields I'm going to populate in the table: TSOS_OFFENSE = [:team_id, :totoff, :rushoff, :passoff, :scoroff, :rzonoff, :fumlost, :passhint, :tolost, :sacksall, :tackflossall, :passeff, :firdwns, :thrdwncon, :fthdwncon] "array" refers to the stats that were pulled in rake. They look and appear just like the following if I perform a puts array.inspect: {18=>{:tolost=>15, :passoff=>195.5, :fthdwncon=>44.44, :sacksall=>2.42, :scoroff=>27.0, :tackflossall=>6.08, :rzonoff=>0.85, :passeff=>130.13, :fumlost=>7, :firdwns=>19.83, :totoff=>398.83, :passhint=>8, :thrdwncon=>37.34, :rushoff=>203.33} 55=>{:tolost=>17, :passoff=>121.5, :fthdwncon=>40.0, :sacksall=>2.42, :scoroff=>18.08, :tackflossall=>4.38, :rzonoff=>0.91, :passeff=>94.95, :fumlost=>9, :firdwns=>13.67, :totoff=>270.17, :passhint=>8, :thrdwncon=>28.85, :rushoff=>148.67} etc... I just don't know how to iterate through this type of array. As you can see the array houses the exact names of my constant... Any help would be appreciated... -- 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 rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---