从rails请求页面时,我会遇到奇怪的行为。
第一次调用<%= link_to "Start »", '/app', role: "button" %>
将使我进入视图而不加载任何资产,除了布局底部包含的一个js文件(</body>
之后)。这导致了一个丑陋的功能页面。
Started GET "/app" for 10.0.2.2 at 2014-05-08 16:09:51 +0000
Processing by AppController#index as HTML
User Load (0.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Authentication Load (0.2ms) SELECT "authentications".* FROM "authentications" WHERE "authentications"."user_id" = $1 ORDER BY "authentications"."id" ASC LIMIT 1 [["user_id", 1]]
Rendered app/_google_maps.html.erb (11.3ms)
Rendered app/index.html.erb within layouts/application (45.9ms)
Completed 200 OK in 886ms (Views: 129.4ms | ActiveRecord: 2.7ms)
Started GET "/assets/app.js?body=1" for 10.0.2.2 at 2014-05-08 16:09:52 +0000
第二次调用它将获得我通常期望的结果 - 加载页面及其所有元素。
Started GET "/app" for 10.0.2.2 at 2014-05-08 16:10:56 +0000
Processing by AppController#index as HTML
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
Authentication Load (0.2ms) SELECT "authentications".* FROM "authentications" WHERE "authentications"."user_id" = $1 ORDER BY "authentications"."id" ASC LIMIT 1 [["user_id", 1]]
Rendered app/_google_maps.html.erb (13.7ms)
Rendered app/index.html.erb within layouts/application (35.3ms)
Completed 200 OK in 561ms (Views: 111.4ms | ActiveRecord: 0.9ms)
Started GET "/assets/bootstrap.min.css?body=1" for 10.0.2.2 at 2014-05-08 16:10:57 +0000
Started GET "/assets/jquery.js?body=1" for 10.0.2.2 at 2014-05-08 16:10:57 +0000
Started GET "/assets/app.css?body=1" for 10.0.2.2 at 2014-05-08 16:10:57 +0000
Started GET "/assets/application.css?body=1" for 10.0.2.2 at 2014-05-08 16:10:57 +0000
Started GET "/assets/bootstrap-slider.css?body=1" for 10.0.2.2 at 2014-05-08 16:10:57 +0000
Started GET "/assets/font-awesome.min.css?body=1" for 10.0.2.2 at 2014-05-08 16:10:57 +0000
Started GET "/assets/bootstrap.min.js?body=1" for 10.0.2.2 at 2014-05-08 16:10:57 +0000
Started GET "/assets/jquery_ujs.js?body=1" for 10.0.2.2 at 2014-05-08 16:10:57 +0000
Started GET "/assets/turbolinks.js?body=1" for 10.0.2.2 at 2014-05-08 16:10:57 +0000
Started GET "/assets/bootstrap-slider.js?body=1" for 10.0.2.2 at 2014-05-08 16:10:57 +0000
Started GET "/assets/application.js?body=1" for 10.0.2.2 at 2014-05-08 16:10:57 +0000
Started GET "/assets/app.js?body=1" for 10.0.2.2 at 2014-05-08 16:10:57 +0000
我在这里缺少什么?
答案 0 :(得分:0)
迈克尔在评论中提出这是一个涡轮增压链接。所以,我所做的是将data-no-turbolink=true
添加到锚点,如下所示:<%= link_to "Start »", app_path, data: { no_turbolink: true } %>
- 这解决了我的问题。
修改强>
更好的解决方案:
<body data-no-turbolink=true>