Rails 3.1.3 - 从供应商/资产/样式表中的子文件夹加载资产
我想从 app/vendor/assets/stylesheets/twitter 加载外部样式表...但 Sprockets 一直抱怨找不到该文件。我的 app/assets/stylesheets/application.css 看起来像这样:
/*
*= require_self
*= require bootstrap
*= require sass_main
*/
我尝试将子目录添加到资产路径中,如下所示:
config.assets.paths << "#{Rails.root}/app/vendor/assets/stylesheets/twitter"
...但没有运气。我该怎么办?
I want to load an external stylesheet from app/vendor/assets/stylesheets/twitter... but Sprockets keeps complaining that the file can't be found. My app/assets/stylesheets/application.css looks like this:
/*
*= require_self
*= require bootstrap
*= require sass_main
*/
I tried adding the subdirectory to the asset path like this:
config.assets.paths << "#{Rails.root}/app/vendor/assets/stylesheets/twitter"
...but no luck. What I gotta do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试:
Try:
如果
require_directory ./twitter
成功了,那么我相信问题出在您的资产路径中的拼写错误:您确定您在
app/ 下有
/vendor
dir ?通常它位于Rails.root
中,因此您一开始将其添加到config.assets.paths
中是正确的,但您应该省略/app< /code> 之间像这样:
If
require_directory ./twitter
did the trick then I believe the problem was in typo in your asset path:Are you sure you were having
/vendor
dir underapp/
? Usually this sits inRails.root
so you were correct at the beginning by adding it toconfig.assets.paths
but you should have left out the/app
in between like this: