Rob,

I think this is probably the better way using your example:

RAKE

update_tsos_offense.table_update(TSOS_OFFENSE, stats)  # constant, # 
array

MODEL

def self.table_update(constant, array)
  if compiled_this_week.find(:all).empty?
    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
      self.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

That way I send a constant holding the fields that will be populated in 
the table, the array (stats) which contains the data.

I haven't tested this yet - but I think I'm close..

-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to