title: Rails - Geocoder Gem : geocoded_by with 2 tables
body: <p>I'm used to work with the geocoder gem the way I saw in <a href="http://railscasts.com/episodes/273-geocoder" rel="nofollow">http://railscasts.com/episodes/273-geocoder</a>, but my model is becoming a bit more complex than the given example.</p>
  
  <p>Now, I would like to use 2 models :<br/>
  - "City", which has a "name" attribute <br/>
  and <br/>
  - "Location", which has "latitude", "longitude" and "city_id" attributes <br/><br/>
  This way, the location will have default latitude and longitude values, and, later, we can precise them.</p>
  
  <p>The question is, in the Location model, how can I specify that the location is geocoded_by the name in the City model ?</p>
  
  <p>I was looking for something simple, like that :</p>
  
  <pre><code>geocoded_by :city, :name
  </code></pre>
  
  <p>or</p>
  
  <pre><code>geocoded_by self.city.name
  </code></pre>
  
  <p>Thank you for your help.</p>
  
  <p>Edit:
  Here are the current models:</p>
  
  <pre><code>class Location&lt; ActiveRecord::Base
    attr_accessible :city_id, :latitude, :longitude
    belongs_to :city
    geocoded_by ??? (how to specify the city.name value ?)
    after_validation :geocode  
  end
  
  class City &lt; ActiveRecord::Base
    attr_accessible :name
    has_many :locations
  end
  </code></pre>