6

I was in the process of upgrading a Rails 5.0.1 app to Rails 5.1 and encountered some deprecation warnings. I was able to resolve all but one.

I did some searching around and didn't find a definitive answer.

Background

This is an app that was just completed. I just updated the rails version to 5.1

I have some RSpec request specs. They test redirection in (Devise) login. This error shows up in those specs.

Controller specs run just fine. I see this warning in request specs concerning css, js, images etc.

I do have the dashboard.js in the asset pipeline. And there is an app/assets/javascripts/dashboard.coffee file.

# 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
]

Warning

Here is the warning I see.

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)

What I tried

  • pre-compiling assets manually didn't solve

I appreciate any advice on how to resolve this warning.

What I think is that the asset pipeline is been bypassed for specs.

Ziyan Junaideen
  • 3,270
  • 7
  • 46
  • 71

2 Answers2

2

You need to add dashboard.js in the assets.rb file to know rails that it needs to be precompiled..

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

Add this line, actually you just need to uncomment it and add the file name.

Md. Farhan Memon
  • 6,055
  • 2
  • 11
  • 36
  • and where are those files residing in? – Md. Farhan Memon Jun 02 '17 at 04:21
  • I have found that putting `scss` files under `public` folder, using a 3rd party `sass` watcher and compiler and skipping `assets` pipeline gives better performance while live reloading using `browsersync`. – W.M. Sep 06 '17 at 18:30
0

I had the same problem after I upgraded Rails to 5.1

I assume that you keep some of your assets in the ./public folder

You can either move your assets from ./public into ./app/assets folder. Or just add skip_pipeline: true option, like this:

image_url("body-bg.gif", skip_pipeline: true)
Hirurg103
  • 4,783
  • 2
  • 34
  • 50