2014-02-21 3 views
0

의 오른쪽 값을 표시하는 방법을 선택-선택하고 내가 편집하고있는 사람를 선택 권리 ethinicty 을보고 싶어 3 수집레일 내 편집 양식의 선택 목록을 편집

<%= simple_nested_form_for @person do |f| %> 
    <%= f.input :first_name %> 
    <%= f.input :last_name %> 
    <%= f.input :ethnicity, 
       collection: Person.select('distinct ethnicity'), 
       :label_method => :ethnicity, 
       :input_html => {:class => 'chosen-select'} %> 
<input type="submit" value="Update Person" name="commit" class="btn-edit"> 
<% end %>  

Person.rb

class Person < ActiveRecord::Base 
    attr_accessible :ethnicity, :description, :first_name, :last_name 

내가 편집에서 선택한 민족에 대한 올바른 값을합니다. 어떻게해야합니까? 아래 그림과 같이 내가 선택 목록에 대한 value_method를 설정 편집 페이지

답변

1

오전 때 나는 민족의 값이없는 무슨 짓을했는지와
:

<%= f.input :ethnicity, 
       collection: Person.select('distinct ethnicity'), 
       :label_method => :ethnicity, 
       :value_method => :ethnicity,  
       :input_html => {:class => 'chosen-select'} %>