title: Ruby on rails , looping through a table in a controller
body: <p>I have  my application designed using Php-Mysql and I should convert it to rails. I have a table called coordinates and a search form for the same.I have two variables called latitude and longitude. the coordinates table cantains city,latitude and longitude. when the user enters the city and if it's found in the table then it should assign that  city to the matching city in the coordinates table and the latitude and longitude should be assigned to the  respective latitude and longitude in the coordinates table.
  my code</p>
  
  <pre><code>$result = mysqli_query($con,"SELECT * FROM coordinates");
  
      while($row = mysqli_fetch_array($result)) 
      {
          if(strtolower($location) == strtolower($row['city'])){
              $latitude = (float) $row['latitude'];
              $longitude = (float) $row['longitude'];
              break;
          }
  </code></pre>
  
  <p>This s my php code . location is entered by the user in the search button. I want the same thing t to b implemented using rails . anyone pls  help me to implement the rails code . thks  in advance`</p>