Rails Average - Discount 0 values -


i create arrays need find averages of follows:

total_rating = [] #add numbers total_rating average = total_rating.inject(:+).to_f / total_rating.size 

how can remove values of 0 average calculation? dont want 0 row computed in average calculation.

total_rating.reject(&:zero?)  

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -