0

我有一个相对简单的 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
4

1 回答 1

0

从上面的评论

在 Rails 4 中,默认情况下包含 Turbolinks,因此您可能需要为page:change.

于 2013-07-19T14:43:09.813 回答