2017-08-06 57 views
0

我在启动Puma后第一次打开我的应用程序时面临此错误。 红宝石版本:2.4时,Rails:5.0.2ActionView :: Template :: Error(迭代期间无法将新密钥添加到哈希中)

服务器日志如下:

=> Booting Puma 
=> Rails 5.0.2 application starting in development on http://localhost:3000 
=> Run `rails server -h` for more startup options 
Puma starting in single mode... 
* Version 3.8.2 (ruby 2.4.0-p0), codename: Sassy Salamander 
* Min threads: 5, max threads: 5 
* Environment: development 
* Listening on tcp://localhost:3000 
Use Ctrl-C to stop 
Started GET "/" for 127.0.0.1 at 2017-08-06 16:47:47 +0500 
    ActiveRecord::SchemaMigration Load (57.9ms) SELECT "schema_migrations".* FROM "schema_migrations" 
Processing by HomeController#index as HTML 
    User Load (50.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]] 
    (0.4ms) BEGIN 
    SQL (1.5ms) UPDATE "users" SET "current_sign_in_at" = $1, "last_sign_in_at" = $2, "sign_in_count" = $3, "updated_at" = $4 WHERE "users"."id" = $5 [["current_sign_in_at", 2017-08-06 11:47:50 UTC], ["last_sign_in_at", 2017-08-05 10:49:56 UTC], ["sign_in_count", 9], ["updated_at", 2017-08-06 11:47:50 UTC], ["id", 1]] 
    (7.7ms) COMMIT 
    Rendering home/index.html.erb within layouts/application 
    CaseFile Load (26.9ms) SELECT "case_files".* FROM "case_files" WHERE "case_files"."assigned_to" = $1 [["assigned_to", 1]] 
    Rendered home/index.html.erb within layouts/application (161.1ms) 
    Rendered shared/_header.html.erb (4.1ms) 
    Rendered shared/_menu.html.erb (1.0ms) 
    Rendered shared/_flash.html.erb (0.9ms) 
    Rendered shared/_footer.html.erb (0.4ms) 
Completed 200 OK in 38804ms (Views: 38103.1ms | ActiveRecord: 410.7ms) 


Started GET "/" for 127.0.0.1 at 2017-08-06 22:06:31 +0500 
Started GET "/" for 127.0.0.1 at 2017-08-06 22:06:31 +0500 
Processing by HomeController#index as HTML 
    User Load (76.4ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]] 
    Rendering home/index.html.erb within layouts/application 
    CaseFile Load (0.8ms) SELECT "case_files".* FROM "case_files" WHERE "case_files"."assigned_to" = $1 [["assigned_to", 1]] 
    Rendered home/index.html.erb within layouts/application (117.8ms) 
Processing by HomeController#index as HTML 
    User Load (1.8ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2 [["id", 1], ["LIMIT", 1]] 
    Rendering home/index.html.erb within layouts/application 
    CaseFile Load (0.9ms) SELECT "case_files".* FROM "case_files" WHERE "case_files"."assigned_to" = $1 [["assigned_to", 1]] 
    Rendered home/index.html.erb within layouts/application (7.6ms) 
Completed 500 Internal Server Error in 1365ms (ActiveRecord: 3.1ms) 



ActionView::Template::Error (can't add a new key into hash during iteration): 
    7:  <%= csrf_meta_tags %> 
    8:  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> 
    9:  <%= include_gon %> 
    10:  <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => 'reload' %> 
    11:  <%= javascript_include_tag 'application', 'data-turbolinks-track' => 'reload' %> 
    12: </head> 
    13: 

app/views/layouts/application.html.erb:10:in `_app_views_layouts_application_html_erb___1144907443235232126_69907219735460' 

我搜索的净却得到了不少相关的线程那些没有得到解决。有人可以帮忙吗?

回答

0

可能是由于多次请求相同的资源?我的路由配置可能会引发这样的:

Rails.application.routes.draw do 
    devise_for :users 
    root 'home#index' 
    get 'home/index' 

事实上,加入路线后,我忘了删除得到路线。评论它后,我无法重现此错误。如果有人承认我的答案并详细说明根本原因,它仍然会有所帮助。

编辑:

找到罪魁祸首。它实际上是Chrome浏览器预取页面,而我在地址栏输入localhost:3000。因此,当我第一次打开我的应用程序时,我在类似的时间收到两个请求。

Chrome的设置使要做到这一点:

设置 - >显示高级设置 - >隐私

预提取资源,加载网页更快速

相关问题