我有
users.scss
@font-face {
font-family: scriptina;
src: asset-url('scriptina.ttf')
}
.script {
font: scriptina, cursive;
}
生成
@font-face {
font-family: scriptina;
src: url(/scriptina.ttf);
}
/* line 18, C:/Users/Chloe/workspace//app/assets/stylesheets/users.scss */
.script {
font: scriptina, cursive;
}
但http://localhost:3000/scriptina.ttf
会生成
路由错误
没有路线匹配[GET]" /scriptina.ttf"
$ ls app/assets
config images javascripts scriptina.ttf stylesheets
Rails 5
参考:http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets
答案 0 :(得分:1)
一种方法(概述here)将fonts
文件夹添加到app/assets
,然后通过编辑{{}将其添加到您的应用将查找资源的文件夹中1}}:
config/application.rb
然后将# config/application.rb
config.assets.paths << Rails.root.join("app", "assets", "fonts")
移至scriptina.ttf
,然后您的app/assets/fonts
助手将引用您字体的有效路径。