gpt4 book ai didi

ruby-on-rails - RSpec 请求警告 - Rails 5.1 升级 - Assets 管道中不存在 Assets

转载 作者:数据小太阳 更新时间:2023-10-29 07:35:29 27 4
gpt4 key购买 nike

我在将 Rails 5.0.1 应用程序升级到 Rails 5.1 的过程中遇到了一些弃用警告。除了一个,我能够解决所有问题。

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

背景

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

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

Controller 规范运行良好。我在有关 css、js、图像等的请求规范中看到此警告。

Assets 管道中确实有 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)

我尝试了什么

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

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

我认为 Assets 管道已被规范绕过。

最佳答案

需要在assets.rb文件中添加dashboard.js才能知道rails需要预编译..

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

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

关于ruby-on-rails - RSpec 请求警告 - Rails 5.1 升级 - Assets 管道中不存在 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44320488/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com