2013-08-08 2 views
0

문제가 있습니다, 지역을 선택할 수 없습니다. 세 가지 모델이 있습니다. spot => city, city => region. 모델 스포트에서는 필드 영역을 havent합니다.간단한 형태로 선택

class Spot < ActiveRecord::Base 
    belongs_to :city 
end 

class City < ActiveRecord::Base 
    belongs_to :region 
end 

class Region < ActiveRecord::Base 
end 

= simple_form_for(@spot, :url => admin_spot_index_path) do |f| 
    = f.error_notification 
    = f.association :city, :collection => City.all, label: false 
    #TODO 
    Select region ?? 

단순한 형태로 선택 영역을 나타내는 방법은 무엇입니까?

답변

0

시도 레일은 다음과 같이 simple_form에 래퍼 :

= simple_form_for(@spot, :url => admin_spot_index_path) do |f| 
    = f.error_notification 
    = f.association :city, :collection => City.all, label: false 
    = f.input :region do 
    = f.select :region, Region.all.map { |r| [r.name, r.id] }, :prompt => "select Region" 

감사

+0

감사합니다. 이것은 필요하지 않습니다 =) 모델 지점에서 지역 모델과 연결되지 않았으므로 오류가 발생합니다. # vadus

+0

에 대해 정의되지 않은 메서드 인 'region'은 spot 필드에 region_id를 저장하려고합니다. 또는 무엇을? –

관련 문제