레일 용 chosen gem으로 자동 완성을 구현하려고합니다. 나는 내가 simpleform 보석을 사용하는 형태를 구현하기 위해 노력하고있어 2.0.2 레일 3.2.8 & 간단한 양식을 사용하고 수확 here하여 자바 스크립트 플러그인선택한 플러그인을 레일과 함께 사용 선택
된다. Simpleform에서 사용자가 속할 수 있거나 속할 수있는 모든 기관 (데이터베이스의 다른 테이블)을 선택하는 연관성 방법을 사용하고 있습니다.
내가 2 개 railscasts 에피소드 #102을 결합에서 그것을 함께 조각 노력하고 있었고, #258
나는
gem 'chosen-rails'
내가 항목을 필요로 넣어했습니다 내 보석 파일의 보석을 설치 한 application.js
//= require chosen-jquery
& application.css에서
,*= require chosen
내 users.js.coffee 파일 여기
jQuery ->
$('#user_bankinst_name').chosen();
에 전화를 배치 한 난에 플러그인을 사용하기 위해 노력하고있어 형태이다. 그것은 "f.association"라인입니다.
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= f.error_notification %>
<%= f.input :email, :required => true, :autofocus => true, :label => 'Username (Your Email)', :placeholder => 'Email Address' %>
<%= f.input :password, :required => true, :autofocus => true, :label => 'Password', :placeholder => 'Password' %>
<%= f.input :password_confirmation, :required => true, :autofocus => true, :label => 'Confirm Password', :placeholder => 'Password Confirmation' %>
<%= f.association :bankinst, :collection => Bankinst.order(:FinancialInstitutionName), :required => true, :autofocus => true, :label => 'Pick an Institution', :label_method=>:FinancialInstitutionName, :id => 'user_bankinst_name' %>
<%= f.button :submit, "Sign Up >>", class: 'btn btn-inverse' %>
<% end %>
내가 뭘 잘못하고 있니? 도와 주셔서 감사합니다.