简体   繁体   English

如何仅在Rails中使用相对路径,而不使用资产管道?

[英]How to only use relative paths in Rails, instead of using the asset pipeline?

I am trying to integrate components from multiple websites into my own Rails website. 我正在尝试将来自多个网站的组件集成到我自己的Rails网站中。 Their images, CSS files, and JavaScript files are numerous and scattered in deeply nested directories. 它们的图像,CSS文件和JavaScript文件很多,并且分散在深层嵌套的目录中。 If I copy their folders into the 'app/assets' folder, I will get something like this: 如果我将他们的文件夹复制到“ app / assets”文件夹中,则会得到以下信息:

app/assets/website1/a/b/c/d/image1.jpg
app/assets/website2/e/f/g/style.css
app/assets/website3/h/i/j/k/custom.js

If I try to reference the above items with: 如果我尝试通过以下方式引用上述项目:

<img src="/app/assets/website1/a/b/c/d/image1.jpg">
<link rel="stylesheet" href="/app/assets/website2/e/f/g/style.css">
<script src="/app/assets/website3/h/i/j/k/custom.js"></script>

respectively, they will not load at all. 分别,它们将根本不会加载。 I would greatly prefer to use relative paths because using the asset pipeline would be a nightmare with such deeply nested directories. 我将更喜欢使用相对路径,因为使用资产管道对于如此深层嵌套的目录将是一场噩梦。 Is what I am describing even possible? 我所描述的甚至可能吗?

Have you tried disabling the asset pipeline in config/application.rb by adding the following line to it ? 您是否尝试通过在config / application.rb中添加以下行来禁用资产管道?

config.assets.enabled = false

Havn't tested it. 没有测试过。 Let me know if it works. 让我知道它是否有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM