2016-07-17 2 views
0

I가 다음과 같은 모델 .. 건물 has_many> 마루 has_many> 객실레일 아래로 세 번째 수준 option_groups_from_collection_for_select 사용

내가 이상 갈하여 apidock option_groups_from_collection_for_select및 단지 양식 필드를 만들 2 단계를 선택하십시오. 방을 선택하여 3 단계 아래로 설정할 수 있습니까, 아니면 불가능하며 다른 옵션을 살펴 봐야합니까? 감사.

편집 : (일부 추가 정보)

building.rb

class Building < ActiveRecord::Base 
    has_many :floors 
end 

floor.rb

class Floor < ActiveRecord::Base 
    belongs_to :building 
    has_many: rooms 

end 

room.rb

형태의
class Room < ActiveRecord::Base 
    belongs_to :floor 
end 

내가 방을 선택하지만, API의 예를 다음, 나는 단지 수까지 바닥 수준으로 설정할 수있게하려면
<div class="form-group"> 
       <% loc_options = option_groups_from_collection_for_select(@buildings, :floors, :name, :id, :name)%> 
       <%= f.label :location, 'Location' %><br /> 
       <%= f.select :location, loc_options, {include_blank: 'Where is it located?'}, class:'form-control' %> 
      </div> 

.

+0

몇 가지 코드를 게시 할 수 있습니까? 모델 연결과 nested_attributes_for를 사용하면 약간의 추가 정보로 – oreoluwa

+0

이 업데이트됩니다. – Kr0n0s

답변

0

HTML 사양은 2 단계 만 허용하므로 대신 아약스를 사용하여 3 개의 선택 상자를 선택하여 그 아래의 각 선택 필드 옵션을 채 웁니다.

관련 문제