Search code examples
belongs-torails-geocoder

Geocoder Gem - Ruby On Rails - Foreign Key ( belongs_to )


I have an event model which has city, state, country as foreign keys. Like below

class CreateEvents < ActiveRecord::Migration
  def change
    create_table :events do |t|
      t.integer :user_id
      t.string :name
      t.date :end_date
      t.text :venue
      t.integer :city_id
      t.integer :state_id
      t.integer :country_id
      t.timestamps
    end
    add_index :events, :user_id
    add_index :events, :name, :unique => true
  end
end

I am trying to use the Geocoder Gem by Alex Reisner . But the problem is that to i have define the from the same model. this is the code suggested

geocoded_by :address

def address
  [venue, city, state, country].compact.join(', ')
end

Can anyone help me figure out how i can write a helper that will allow me to get the real names of the city, state and country instead of the ids?

https://github.com/alexreisner/geocoder


Solution

  • Geocoder Gem doesn't support this feature yet,