首页 文章

rails 3.1.1自动完成

提问于
浏览
1

我正在尝试在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&images目录复制到app / assets / stylesheets中 .

然后我 Build 了一个链接,所以我可以将它作为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插件或更好的教程?

1 回答

  • 1

    我最终在coffee-script和jquery-ui的帮助下手动完成了它

    这是我的笔记,以防其他人被卡住:https://gist.github.com/1347080

相关问题