2012-03-22 2 views
0

도시, 주, 국가가 외래 키 인 이벤트 모델이 있습니다. 아래처럼Geocoder Gem - Ruby On Rails - 외래 키 (belongs_to)

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 

Alex Reisner가 지오 코더 젬을 사용하려고합니다. 하지만 문제는 동일한 모델에서 정의 할 수 있다는 것입니다. 이 코드는 제안이다

geocoded_by : 주소

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

누구도 날 내가 나를 대신 도시, 주 및 국가의 실제 이름을 얻을 수 있도록하는 도우미를 쓸 수있는 방법을 알아낼 도움이 될 수 있습니다 ids?

https://github.com/alexreisner/geocoder

답변

0

지오 코더 보석은 아직이 기능을 지원하지 않습니다

관련 문제