title: Rails add elements to array
body: <p>I have a method to calculated the average for a given set of records: </p>
  
  <pre><code>input = params[:recommendation_ratings].values  # The params are sent from radio_tags in my view.
  
  input.each do |mini_params|
  rating_id = mini_params[:rating_id]
  l = Rating.find(rating_id) #Find record on Rating table. 
  l.rating #Get value associated with rating_id
  total_rating = []
  total_rating &lt;&lt; l.rating
  average = total_rating.inject{ |sum, el| sum + el }.to_f / total_rating.size
  puts average
  end
  </code></pre>
  
  <p>l.rating is not being appended to the total_rating array. The puts average is being printed as: </p>
  
  <pre><code>3.0
  3.0
  3.0
  3.0
  3.0
  </code></pre>
  
  <p>How do I append each of the ratings being returned to the array to calculated the average,and other math functions. </p>