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

标签 ruby-on-rails ruby rspec ruby-on-rails-5.1

我在将 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/

相关文章:

ruby-on-rails - 为什么每个方法都需要将它循环的值分配给一个变量?

mysql - Rails 控制台通过 id 数组查找用户

Ruby - 如何在数据包中做 DSCP 标记?

ruby-on-rails - 我如何断言 Cucumber 中模型的存在?

ruby-on-rails - Rspec:使用 super(args) 初始化 Controller 类时,rspec-rails 是否存在问题?

ruby-on-rails - 3.0.1升级后无法启动rails server

java - 如果使用 ruby​​ on rails、python 或 java 可以做得更好,为什么还要使用 php 框架进行编程?

ruby-on-rails - FactoryGirl、Rspec 和复杂的数据库结构

ruby - 在这种情况下 << 是什么?

ruby-on-rails - 如何设置不记名 token 参数以使用 Rswag UI 测试 Rails API