From: shawn bright Date: 2006-12-22T06:47:33+09:00 Subject: prob with each_with_index ------=_Part_60237_6993815.1166737649824 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline lo there all, i am having a problem making each_with_index do what i need it to do. the issue is... i need to evaluate the gpm of a flow sensor. we are skipping over three database entries to get the values. difference in value / difference in time = gpm. ok, easy enough. but this code @flow_sensor.flow_hits.each_with_index do |hit, i| if i > 4 # start with 3rd hit in db time_diff = hit[i].date_time.to_i - hit[i-3].date_time.to_i value_diff = hit[i].value - hit[i-3].value min = time_diff / 60 val = value_diff / min plots.push(val) times.push(hit[i].date_time) end end is giving me a nil value evaluating nil.date_time this is for a rails app by the way. i know i have the models set up right, because other functions are working. thats why i think my structure is wrong. thanks. ------=_Part_60237_6993815.1166737649824--