3

アプリケーション.css:

*= require_self
*= require foundation_and_overrides
*= require_tree .
*/

アプリケーション.js:

*= require jquery
*= require jquery_ujs
*= require foundation
*= require jquery_nested_form
*= require highcharts/highcharts
*= require turbolinks
*= require_tree .
$(function(){ $(document).foundation(); });

Application.html.erb (財団によって生成):

<!DOCTYPE html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7 ]> <html class="ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
  <head>
<meta charset="utf-8" />

<!-- Uncomment to make IE8 render like IE7 -->
<!-- <meta http-equiv="X-UA-Compatible" content="IE=7" /> -->

<!-- Set the viewport width to device width for mobile -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title>

<%= stylesheet_link_tag    "application" %>
<%= javascript_include_tag "vendor/custom.modernizr" %>
    <%= csrf_meta_tags %>
  </head>

  <body>

  <header>
    <nav class="top-bar">
    <%= render 'layouts/nav' %>
    </nav>
    <%= render 'layouts/flash' %>
  </header>

  <section>
    <%= yield %>
  </section>

  <footer>
    <%= render 'layouts/footer' %>
  </footer>


    <%= javascript_include_tag "application" %>
  </body>
</html>

開発ログ:

Started GET "/" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Processing by UsersController#show as HTML
Processing by UsersController#show as HTML
  Rendered users/show.html.erb within layouts/application (0.1ms)
  Rendered users/show.html.erb within layouts/application (0.1ms)
  Rendered layouts/nav/_director.html.erb (0.6ms)
  Rendered layouts/nav/_director.html.erb (0.6ms)
  Rendered layouts/nav/_manager.html.erb (0.4ms)
  Rendered layouts/nav/_manager.html.erb (0.4ms)
  Rendered layouts/nav/_supervisor.html.erb (0.2ms)
  Rendered layouts/nav/_supervisor.html.erb (0.2ms)
  Rendered layouts/_nav.html.erb (3.2ms)
  Rendered layouts/_nav.html.erb (3.2ms)
  Rendered layouts/_flash.html.erb (0.1ms)
  Rendered layouts/_flash.html.erb (0.1ms)
  Rendered layouts/_footer.html.erb (0.1ms)
  Rendered layouts/_footer.html.erb (0.1ms)
Completed 200 OK in 14ms (Views: 12.7ms | ActiveRecord: 0.3ms)
Completed 200 OK in 14ms (Views: 12.7ms | ActiveRecord: 0.3ms)
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.alerts.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.alerts.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.dropdown.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.dropdown.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.forms.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.forms.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.joyride.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.joyride.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.clearing.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.clearing.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.magellan.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.magellan.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.orbit.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.orbit.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.reveal.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.reveal.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.section.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.section.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.cookie.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.cookie.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.topbar.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.topbar.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.interchange.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.interchange.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.tooltips.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.tooltips.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.placeholder.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.placeholder.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.abide.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/foundation.abide.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/jquery_nested_form.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/jquery_nested_form.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/index.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/foundation/index.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/highcharts/highcharts.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/highcharts/highcharts.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/turbolinks.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/turbolinks.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2013-08-30 13:27:35 +0100

ご覧のとおり、各アセットを 2 回ロードしています。さらに、私は を使用してnested_formいるため、クリックしてネストされたフォームを追加すると、1 つだけでなく多くのフォームが追加されます。ただし、ページを更新すると、フォームは期待どおりに機能します。

を一番上に移動しようとしまし<%= javascript_include_tag "application" %>たが、ナビゲーション メニューが機能しません。

何か案が?

4

2 に答える 2

2

nav を適切に機能させるには、アプリケーションに追加してから application.jsに追加してみgem 'jquery-turbolinks'てください。これにより、アプリ内のすべての $(document).ready バインドが処理されます。Gemfile//= require jquery.turbolinks

次に、JavaScript タグを先頭に戻します。

そして、ところで、サーバーが 2 つの同時リクエストを取得しているようです (たとえば、ブラウザの 2 つの livereloaded タブから)。

于 2013-08-30T12:53:58.227 に答える
0

二重のサーバー ログで同じ問題が発生しましたが、Rails STDOUT ロガーの問題であることがわかりました。

次のリンクを確認してください。

あなたのものとまったく同じログ

ここで追跡されている問題

Chrome でページ リクエストのタイムラインを確認します。ページのアセットが 1 回だけ読み込まれ、2 回ログに記録される場合、これはおそらく同じ問題です。

于 2013-12-22T09:48:48.973 に答える