我正在尝试在Rails 3.1下运行自动完成功能。
https://github.com/crowdint/rails3-jquery-autocomplete
我一直在关注这个完整的应用示例并更改Rails 3.1的相关部分,但它仍然无效。
https://github.com/crowdint/rails3-jquery-autocomplete-app
这是我的applicaion.js文件
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require autocomplete-rails
//= require_tree .
我已经下载了jquery 1.8.16(勾选了自动填充功能),解压缩并将js复制到我的app / assets / javascript目录,以及css&图像目录到app / assets / stylesheets。
然后我创建了一个链接,因此我可以将其引用为jquery-ui
ln -s jquery-ui-1.8.16.custom.min.js jquery-ui.js
与CSS相同
ln -s jquery-ui-1.8.16.custom.css jquery-ui.css
然后我在application.css
中添加了一个指向我的css的链接 *= require_self
*= require jquery-ui
*= require_tree .
我创建了品牌模型&迁移并添加种子数据,如示例。
然后我按照教程将欢迎控制器添加到以下行:
autocomplete :brand, :name
我修复了routes.rb文件并编辑了表单。
我得到的是没有自动完成工作的表单,我的服务器输出中也没有错误:
% rails s -p 3001
=> Booting WEBrick
=> Rails 3.1.1 application starting in development on http://0.0.0.0:3001
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-11-07 16:35:53] INFO WEBrick 1.3.1
[2011-11-07 16:35:53] INFO ruby 1.9.2 (2011-02-18) [x86_64-linux]
[2011-11-07 16:35:53] INFO WEBrick::HTTPServer#start: pid=12616 port=3001
Started GET "/" for 127.0.0.1 at 2011-11-07 16:35:54 +1100
Processing by WelcomeController#show as HTML
Rendered welcome/show.html.erb within layouts/application (15.7ms)
Completed 200 OK in 98ms (Views: 75.6ms | ActiveRecord: 0.0ms)
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2011-11-07 16:35:55 +1100
Served asset /application.css - 304 Not Modified (0ms)
Started GET "/assets/jquery-ui.css?body=1" for 127.0.0.1 at 2011-11-07 16:35:55 +1100
Served asset /jquery-ui.css - 304 Not Modified (5ms)
Started GET "/assets/jquery-ui-1.8.16.custom.css?body=1" for 127.0.0.1 at 2011-11-07 16:35:55 +1100
Served asset /jquery-ui-1.8.16.custom.css - 304 Not Modified (1ms)
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2011-11-07 16:35:55 +1100
Served asset /jquery.js - 304 Not Modified (1ms)
Started GET "/assets/welcome.css?body=1" for 127.0.0.1 at 2011-11-07 16:35:55 +1100
Served asset /welcome.css - 304 Not Modified (2ms)
Started GET "/assets/jquery-ui.js?body=1" for 127.0.0.1 at 2011-11-07 16:35:55 +1100
Served asset /jquery-ui.js - 304 Not Modified (5ms)
Started GET "/assets/jquery-ui-1.8.16.custom.min.js?body=1" for 127.0.0.1 at 2011-11-07 16:35:55 +1100
Served asset /jquery-ui-1.8.16.custom.min.js - 304 Not Modified (3ms)
Started GET "/assets/welcome.js?body=1" for 127.0.0.1 at 2011-11-07 16:35:55 +1100
Served asset /welcome.js - 304 Not Modified (2ms)
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2011-11-07 16:35:55 +1100
Served asset /application.js - 304 Not Modified (0ms)
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2011-11-07 16:35:55 +1100
Served asset /jquery_ujs.js - 304 Not Modified (1ms)
Started GET "/assets/autocomplete-rails.js?body=1" for 127.0.0.1 at 2011-11-07 16:35:55 +1100
Served asset /autocomplete-rails.js - 304 Not Modified (1ms)
我在这里缺少什么? 是否有更新的Rails 3.1插件或更好的教程?
答案 0 :(得分:1)
我最终在coffee-script和jquery-ui
的帮助下手动完成以下是我的笔记,以防其他人被卡住:https://gist.github.com/1347080