我有一个相对简单的Rails 4应用程序(在nitrous.io上运行)正在做一些奇特的事情。我有一个通过GET请求加载的表单,当加载表单页面时,rails服务器只呈现HTML,而不是任何资产。
Started GET "/posts/new" for 198.84.233.70 at 2013-07-19 06:40:16 +0000
Processing by PostsController#new as HTML
Rendered posts/_comments_form.html.erb (4.1ms)
Rendered posts/new.html.erb within layouts/application (22.5ms)
Completed 200 OK in 39ms (Views: 36.6ms | ActiveRecord: 0.0ms)
结果是我的jQuery绑定(实际上根本没有JavaScript)都没有被执行。因此页面无法正常工作。
如果我重新加载页面(通过单击浏览器上的“刷新”按钮),则会提供所有资源,所有JavaScript都会执行,一切正常。
Completed 200 OK in 62ms (Views: 60.7ms | ActiveRecord: 0.0ms)
Started GET "/posts/new" for 198.84.233.70 at 2013-07-19 06:40:27 +0000
Processing by PostsController#new as HTML
Rendered posts/_comments_form.html.erb (2.5ms)
Rendered posts/new.html.erb within layouts/application (49.5ms)
Completed 200 OK in 62ms (Views: 60.7ms | ActiveRecord: 0.0ms)
Started GET "/assets/application.css?body=1" for 198.84.233.70 at 2013-07-19 06:40:29 +0000
Started GET "/assets/bootstrap_and_overrides.css?body=1" for 198.84.233.70 at 2013-07-19 06:40:29 +0000
Started GET "/assets/wines.css?body=1" for 198.84.233.70 at 2013-07-19 06:40:29 +0000
Started GET "/assets/jquery.js?body=1" for 198.84.233.70 at 2013-07-19 06:40:29 +0000
Started GET "/assets/jquery_ujs.js?body=1" for 198.84.233.70 at 2013-07-19 06:40:29 +0000
Started GET "/assets/twitter/bootstrap/bootstrap-transition.js?body=1" for 198.84.233.70 at 2013-07-19 06:40:29 +0000
Started GET "/assets/posts.js?body=1" for 198.84.233.70 at 2013-07-19 06:40:29 +0000
Started GET "/assets/application.js?body=1" for 198.84.233.70 at 2013-07-19 06:40:29 +0000
答案 0 :(得分:0)
来自上面的评论
在Rails 4中,默认情况下包含Turbolinks,因此您可能需要包含page:change
的绑定。