rails 自动补全插件
auto_complete插件
首先,下载插件到项目文件夹的\vendor\plugins下
其次,在控制器里引入
class TestAutosController < ApplicationController
# GET /test_autos
# GET /test_autos.xml
auto_complete_for :auto_complete, :tag
def index
@test_autos = TestAuto.all
注意:auto_complete是自动补全的表名,tag是其中的字段。
最后,页面
<%= f.label :tag %><br />
<%= text_field_with_auto_complete :test_auto,:tag %>
其中,test_auto是对象名,tag是字段名
好了,就这么简单!!
上插件