我正在将Rails 5.0.1应用升级到Rails 5.1并遇到一些弃用警告。我能够解决所有问题。
我做了一些搜索并没有找到确定的答案。
这是一个刚刚完成的应用。我刚刚将rails版本更新为5.1
我有一些RSpec请求规范。他们在(Devise)登录中测试重定向。此错误显示在这些规范中。
控制器规格运行得很好。我在有关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)
我很欣赏有关如何解决此警告的任何建议。
我认为资产管道已经被规范绕过了。
答案 0 :(得分:2)
您需要在dashboard.js
文件中添加assets.rb
以了解需要预编译的rails ..
#/config/initializers/assets.rb
Rails.application.config.assets.precompile += %w( dashboard.js )
添加此行,实际上您只需要取消注释并添加文件名。
答案 1 :(得分:0)
将Rails升级到5.1
我假设您将某些资产保留在./public
文件夹中
您可以将资产从./public
移到./app/assets
文件夹中。或仅添加skip_pipeline: true
选项,如下所示:
image_url("body-bg.gif", skip_pipeline: true)