6

我正在将 Rails 5.0.1 应用程序升级到 Rails 5.1 并遇到一些弃用警告。我能够解决除一个以外的所有问题。

我做了一些搜索,但没有找到明确的答案。

背景

这是一个刚刚完成的应用程序。我刚刚将 Rails 版本更新到 5.1

我有一些 RSpec 请求规范。他们在(设计)登录中测试重定向。此错误显示在这些规范中。

控制器规格运行良好。我在有关 css、js、图像等的请求规范中看到了这个警告。

我确实dashboard.js在资产管道中。并且有一个app/assets/javascripts/dashboard.coffee文件。

# config/initializers/assets.rb
Rails.application.config.assets.precompile += %w[
  sites.js
  sites.css
  admin.js
  admin.css
  header.js
  dashboard.js
  dashboard.css
  setup.js
  setup.css
]

警告

这是我看到的警告。

DEPRECATION WARNING: The asset "header.js" is not present in the asset pipeline.Falling back to an asset that may be in the public folder.
This behavior is deprecated and will be removed.
To bypass the asset pipeline and preserve this behavior,
use the `skip_pipeline: true` option.
  (called from _app_views_layouts_dashboard_html_slim__2366450786595837886_80483400 at /home/ziyan/Work/Brevica/churchfoyer/app/views/layouts/dashboard.html.slim:17)

DEPRECATION WARNING: The asset "dashboard.js" is not present in the asset pipeline.Falling back to an asset that may be in the public folder.
This behavior is deprecated and will be removed.
To bypass the asset pipeline and preserve this behavior,
use the `skip_pipeline: true` option.
(called from _app_views_layouts_dashboard_html_slim__2366450786595837886_80483400 at /home/ziyan/Work/Brevica/churchfoyer/app/views/layouts/dashboard.html.slim:18)
DEPRECATION WARNING: The asset "dashboard.css" is not present in the asset pipeline.Falling back to an asset that may be in the public folder.
This behavior is deprecated and will be removed.
To bypass the asset pipeline and preserve this behavior,
use the `skip_pipeline: true` option.
  (called from _app_views_layouts_dashboard_html_slim__2366450786595837886_80483400 at /home/ziyan/Work/Brevica/churchfoyer/app/views/layouts/dashboard.html.slim:19)

DEPRECATION WARNING: The asset "logos/logo-white.png" is not present in the asset pipeline.Falling back to an asset that may be in the public folder.
This behavior is deprecated and will be removed.
To bypass the asset pipeline and preserve this behavior,
use the `skip_pipeline: true` option.
  (called from _app_views_layouts_dashboard__sidebar_html_slim___2324799200884164274_84919380 at /home/ziyan/Work/Brevica/churchfoyer/app/views/layouts/dashboard/_sidebar.html.slim:3)

我试过的

  • 手动预编译资产没有解决

我感谢有关如何解决此警告的任何建议。

我认为资产管道被绕过了规范。

4

2 回答 2

2

您需要dashboard.jsassets.rb文件中添加以了解需要预编译的 rails ..

#/config/initializers/assets.rb
Rails.application.config.assets.precompile += %w( dashboard.js )

添加这一行,实际上你只需要取消注释并添加文件名。

于 2017-06-02T03:58:11.210 回答
0

升级 Rails 后我遇到了同样的问题5.1

我假设您将一些资产保存在./public文件夹中

您可以将资产从./public文件./app/assets夹中移出。或者只是添加skip_pipeline: true选项,如下所示:

image_url("body-bg.gif", skip_pipeline: true)
于 2019-06-12T07:44:03.453 回答