require_tree argument must be a directory in a Rails 5 upgraded app

拈花ヽ惹草 提交于 2019-12-03 04:31:33

I finally figured it out. So because I am doing the upgrade, RailsDiff didn't tell me that I was missing something.

So the error message wasn't incorrect, however, what I forgot to do was to create an empty directory.

In my app/assets/javascripts/cable.js, I had the following:

//= require_tree ./channels

However, I forgot to actually create that folder.

So to fix this, all I had to do was create an empty folder within app/assets/javascripts called channels. Also, because git ignores empty directories, within that newly created folder, I also had to create an empty file called .keep.

So once I did the following, everything worked like a charm:

  • Create folder: app/assets/javascripts/channels
  • Create empty file within that folder: app/assets/javascripts/channels/.keep

Everything works perfectly now.

The problem occurs when using rails new appname --skip-keeps flag - it still tries to require non-existing files and generally is a mistake on Rails team side.

This is just a different approach to the described problem, the main solution works perfectly;

  1. Open app/assets/javascripts/cable.js
  2. Remove autogenerated //= require_tree ./channels, from line 6

Keep your codebase as small as possible, someone skipped the .keeps for a reason.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!