我的控制器:
@products = Product.all
我的观点:
<%= javascript_tag "var products = #{@products.to_json};" %>
<%= form_for @dolist, :html => { :class => 'form-horizontal' } do |f| %>
<%= f.text_field :product, autofocus: true, placeholder: "product", autocomplete: "off", id: "products", data: {provide: "typeahead"} %>
<div class="form-actions">
<%= f.submit 'Submit', :class => 'btn btn-primary' %>
</div>
<% end %>
预输入对我不起作用,我一定遗漏了一些东西。