title: Method of getting current location from IP address in Rails (geocoder and gmaps4rails gems)
body: <p>I have an app which allows users to post Offers based on address they choose. I would like to add the option of saving the address based on the user's current location, determined by the IP address. I'm using the ruby Geocoder gem. This code will pass but it is not saving any address to the db. I'm not sure if it's an issue with my approach or if it is not working because of the development environment. I know that other features of Geocoder e.g. distance calculations don't work in development.</p>
  
  <p><code>current_location</code> is a boolean attribute of the Offer class</p>
  
  <p>In the offers/_form View:</p>
  
  <pre><code>&lt;div class="field"&gt;&lt;br&gt;
        &lt;%= f.label :use_current_location? %&gt;
        &lt;%= f.check_box :current_location %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In the OffersHelper:</p>
  
  <pre><code>def geocode_by_ip_address(offer)
      if :current_location
        offer.address = request.location.address
      end
  end
  </code></pre>
  
  <p>In the Offer Model:</p>
  
  <pre><code>def geo_offer
    geocode_by_ip_address(offer)
  end
  </code></pre>
  
  <p>For the purposes of the my map, gmaps4rails uses the following attributes:</p>
  
  <pre><code>def gmaps4rails_address
      "#{self.address}, #{self.city}, #{self.country}"
  end
  </code></pre>
  
  <p>However the address is not saving (have checked using the console). Would appreciate any help! Many thanks</p>