Ruby on rails 为什么Rails只在页面重新加载时启动?

Ruby on rails 为什么Rails只在页面重新加载时启动?,ruby-on-rails,Ruby On Rails,在我的控制台中,加载页面时,我会得到通常执行的命令列表,如下所示: Started GET "/employees" for ::1 at 2015-07-14 10:36:25 -0400 Processing by EmployeesController#index as HTML Employee Load (0.2ms) SELECT "employees".* FROM "employees" Rendered employees/index.html.erb within

在我的控制台中,加载页面时,我会得到通常执行的命令列表,如下所示:

Started GET "/employees" for ::1 at 2015-07-14 10:36:25 -0400
Processing by EmployeesController#index as HTML
  Employee Load (0.2ms)  SELECT "employees".* FROM "employees"
  Rendered employees/index.html.erb within layouts/application (7.7ms)
  Rendered layouts/_shim.html.erb (0.1ms)
  Rendered layouts/_header.html.erb (0.9ms)
  Rendered layouts/_footer.html.erb (0.1ms)
Completed 200 OK in 438ms (Views: 433.9ms | ActiveRecord: 2.4ms)
...

Started GET "/assets/static_pages.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2015-07-14 10:38:32 -0400


Started GET "/assets/sessions.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2015-07-14 10:38:32 -0400


Started GET "/assets/users.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2015-07-14 10:38:32 -0400


Started GET "/assets/application.self-7c44b34571f9c6f50024ec815db695a00182b9937b48d97c4ac1515ab6b385a0.js?body=1" for ::1 at 2015-07-14 10:38:32 -0400

...
但是,当我重新加载此页面时,我会得到与前面相同的块,但也会得到一个巨大的启动get命令列表,如下所示:

Started GET "/employees" for ::1 at 2015-07-14 10:36:25 -0400
Processing by EmployeesController#index as HTML
  Employee Load (0.2ms)  SELECT "employees".* FROM "employees"
  Rendered employees/index.html.erb within layouts/application (7.7ms)
  Rendered layouts/_shim.html.erb (0.1ms)
  Rendered layouts/_header.html.erb (0.9ms)
  Rendered layouts/_footer.html.erb (0.1ms)
Completed 200 OK in 438ms (Views: 433.9ms | ActiveRecord: 2.4ms)
...

Started GET "/assets/static_pages.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2015-07-14 10:38:32 -0400


Started GET "/assets/sessions.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2015-07-14 10:38:32 -0400


Started GET "/assets/users.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2015-07-14 10:38:32 -0400


Started GET "/assets/application.self-7c44b34571f9c6f50024ec815db695a00182b9937b48d97c4ac1515ab6b385a0.js?body=1" for ::1 at 2015-07-14 10:38:32 -0400

...
这些命令几乎有100个。它们只在我重新加载一个页面时出现,而重新加载哪个页面并不重要

除了可能做不必要的工作和堵塞我的日志之外,我不认为它一定会造成任何损害,但如果我能找到解决办法,那就太好了


为什么会这样?我能做些什么来阻止它吗?

这些请求是您的浏览器为您的页面加载的资源。由于您处于开发模式,它们将作为单独的文件使用

通过将以下内容添加到config/development.rb,可以禁用资产请求的日志记录:


所以这真的没有造成任何伤害?只是堵塞了我的日志?是的,它只是在日志中添加了不必要的信息。你是说config/environment/development.rb文件吗?明白了。我尝试设置config.assets.logger=false,但它仍然显示资产。相反,我只是设置config.assets.debug=false,效果很好。谢谢