2017-02-16 23 views
0

私はRails 4.2 + AngularJS 1.5プロジェクトに取り組んでおり、かなり奇妙な問題に直面しています。プロジェクトのメインWebページをリフレッシュ(F5)しようとすると、リフレッシュが正しく実行されないという大きなチャンスです(9/10としましょう)。その場合は、私が見るすべては私のapplication.html.hamlレイアウトコンテンツ(例えば、単に「ToDoDoo」ヘッダ)である:Rails + AngularJS - ページリフレッシュはローカルホスト上では動作しません

!!! 
%html{"ng-app" => "tododoo"} 
    %head 
    %title Tododoo 
    = stylesheet_link_tag 'application', media: 'all' 
    = javascript_include_tag 'application' 
    = csrf_meta_tags 
    %body 
    .row#header-row 
     .col-md-8.col-md-offset-2 
     %h1#main-header 
      ToDoDoo 

    = yield 

そしてチャンス1/10と、それは適切にページを更新し、その場合には、私は私のレイアウトのコンテンツを参照してくださいだけでなく、実際には/ルート上にレンダリングされる角度テンプレート。それはapp/assets/javascripts/templates/projects/index.html.hamlにあります。今のところ、私のコードは私の問題のために本当に重要だとは思わないが、あなたがそれを見たいと思うなら、私はそれを追加するだろう。

UPDATE:リフレッシュは、私は私のサーバーのコンソールを持っているだけでなく行われた場合:

Started GET "/" for 127.0.0.1 at 2017-02-16 15:16:00 +0200 
Processing by MainController#index as HTML 
    Rendered main/index.html.haml within layouts/application (0.1ms) 
Completed 200 OK in 61ms (Views: 60.8ms | ActiveRecord: 0.0ms) 


Started GET "/assets/bg.jpg" for 127.0.0.1 at 2017-02-16 15:16:00 +0200 

しかし:

Started GET "/" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by MainController#index as HTML 
    Rendered main/index.html.haml within layouts/application (0.1ms) 
Completed 200 OK in 54ms (Views: 53.3ms | ActiveRecord: 0.0ms) 


Started GET "/assets/bg.jpg" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 


Started GET "/projects?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by ProjectsController#index as JSON 
    Project Load (0.4ms) SELECT "projects".* FROM "projects" WHERE "projects"."user_id" = $1 [["user_id", 2]] 
    Task Load (0.4ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 4]] 
    Comment Load (0.4ms) SELECT "comments".* FROM "comments" WHERE "comments"."task_id" = $1 [["task_id", 26]] 
    Rendered projects/_comment.json.jbuilder (0.2ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered shared/_task.json.jbuilder (8.6ms) 
    Comment Load (0.4ms) SELECT "comments".* FROM "comments" WHERE "comments"."task_id" = $1 [["task_id", 27]] 
    Rendered projects/_comment.json.jbuilder (0.2ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.2ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.3ms) 
    Rendered projects/_comment.json.jbuilder (0.5ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.3ms) 
    Rendered shared/_task.json.jbuilder (14.7ms) 
    Comment Load (0.4ms) SELECT "comments".* FROM "comments" WHERE "comments"."task_id" = $1 [["task_id", 28]] 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered shared/_task.json.jbuilder (4.4ms) 
    Rendered projects/_project.json.jbuilder (33.1ms) 
    Task Load (1.6ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 5]] 
    Comment Load (0.4ms) SELECT "comments".* FROM "comments" WHERE "comments"."task_id" = $1 [["task_id", 29]] 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered shared/_task.json.jbuilder (7.0ms) 
    Rendered projects/_project.json.jbuilder (12.7ms) 
    Task Load (0.4ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 6]] 
    Comment Load (0.3ms) SELECT "comments".* FROM "comments" WHERE "comments"."task_id" = $1 [["task_id", 30]] 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered shared/_task.json.jbuilder (8.0ms) 
    Comment Load (1.8ms) SELECT "comments".* FROM "comments" WHERE "comments"."task_id" = $1 [["task_id", 31]] 
    Rendered projects/_comment.json.jbuilder (0.2ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered shared/_task.json.jbuilder (23.2ms) 
    Comment Load (1.5ms) SELECT "comments".* FROM "comments" WHERE "comments"."task_id" = $1 [["task_id", 32]] 
    Rendered projects/_comment.json.jbuilder (0.5ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.2ms) 
    Rendered projects/_comment.json.jbuilder (0.2ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered shared/_task.json.jbuilder (20.0ms) 
    Comment Load (1.2ms) SELECT "comments".* FROM "comments" WHERE "comments"."task_id" = $1 [["task_id", 33]] 
    Rendered projects/_comment.json.jbuilder (0.2ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered shared/_task.json.jbuilder (8.3ms) 
    Comment Load (0.3ms) SELECT "comments".* FROM "comments" WHERE "comments"."task_id" = $1 [["task_id", 34]] 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered shared/_task.json.jbuilder (2.6ms) 
    Comment Load (0.3ms) SELECT "comments".* FROM "comments" WHERE "comments"."task_id" = $1 [["task_id", 35]] 
    Rendered projects/_comment.json.jbuilder (0.1ms) 
    Rendered projects/_comment.json.jbuilder (0.0ms) 
    Rendered shared/_task.json.jbuilder (6.6ms) 
    Rendered projects/_project.json.jbuilder (75.1ms) 
    Rendered projects/index.json.jbuilder (135.1ms) 
Completed 200 OK in 139ms (Views: 128.5ms | ActiveRecord: 9.8ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (1.2ms) 
Completed 200 OK in 5ms (Views: 3.6ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (1.1ms) 
Completed 200 OK in 6ms (Views: 3.9ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (1.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (2.6ms) 
Completed 200 OK in 6ms (Views: 3.8ms | ActiveRecord: 1.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (0.9ms) 
Completed 200 OK in 3ms (Views: 2.5ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (0.9ms) 
Completed 200 OK in 5ms (Views: 4.0ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (0.9ms) 
Completed 200 OK in 3ms (Views: 2.4ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (1.1ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (3.2ms) 
Completed 200 OK in 8ms (Views: 5.3ms | ActiveRecord: 1.1ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (0.9ms) 
Completed 200 OK in 4ms (Views: 2.6ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (1.0ms) 
Completed 200 OK in 4ms (Views: 2.6ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.4ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (1.4ms) 
Completed 200 OK in 6ms (Views: 4.3ms | ActiveRecord: 0.4ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (1.1ms) 
Completed 200 OK in 4ms (Views: 2.9ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.4ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (1.1ms) 
Completed 200 OK in 6ms (Views: 4.6ms | ActiveRecord: 0.4ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (1.1ms) 
Completed 200 OK in 4ms (Views: 2.9ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (1.0ms) 
Completed 200 OK in 4ms (Views: 2.7ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.4ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (1.0ms) 
Completed 200 OK in 4ms (Views: 2.6ms | ActiveRecord: 0.4ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (0.9ms) 
Completed 200 OK in 3ms (Views: 2.5ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (1.0ms) 
Completed 200 OK in 4ms (Views: 2.6ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.3ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (1.1ms) 
Completed 200 OK in 4ms (Views: 2.8ms | ActiveRecord: 0.3ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:35 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.5ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (1.6ms) 
Completed 200 OK in 5ms (Views: 4.0ms | ActiveRecord: 0.5ms) 


Started GET "/tasks?format=json" for 127.0.0.1 at 2017-02-16 15:15:36 +0200 
Processing by TasksController#index as JSON 
    Task Load (0.6ms) SELECT "tasks".* FROM "tasks" WHERE "tasks"."project_id" = $1 [["project_id", 1]] 
    Rendered tasks/index.json.jbuilder (2.0ms) 
Completed 200 OK in 6ms (Views: 4.4ms | ActiveRecord: 0.6ms) 

ない場合、私はちょうどを持っています!ヘロクでそのページの爽やかさはうまくいきます!私はリフレッシュボタンを押すたびにページをリフレッシュします。それは実際に私にとってそのことを変なものにしています。私もPumaサーバーをデフォルトのもの(Webrick)の代わりに私のRailsアプリにインストールし、私のアプリを起動しましたが、それは助けになりませんでした。

私のセットアップで何が間違っているか教えていただけたら本当に感謝します。あなたがコードや何かを見る必要があるかどうかを教えてください。私は、どのコードが問題を解決するのに役立つか分かりません。

答えて

0

最終的に私は答えを見つけました。問題はChrome DevToolsのAngularJSタブ(Batarang拡張機能で提供)のチェックボックス「有効」にチェックが入っていたことです。それは物事を台無しにしていた。明らかにチェックボックスをオフにしておき、実際にアプリをデバッグする場合にのみチェックしてください。

関連する問題