title: storing the values in temp variable before storing it in the desired location
body: <p>I have got a many to many relationship between these to models :- </p>
  
  <p><code>user.rb and city.rb</code>, so that I can access user.cities and city.users.</p>
  
  <p>Once the user clicks add city I want to add those cities in the temp variable like this </p>
  
  <pre><code>temp = []
  city = City.find(params[:id])
  temp &lt;&lt; city
  </code></pre>
  
  <p>then I want to iterate over the temp doing something like this <code>temp.each do |t|...</code>
  then once the user clicks confirm my cities I want to add these cities in <code>user.cities</code></p>
  
  <p>What might be the best approach to get the desired result?</p>