有谁知道如何在Rails 3.1中向资产管道添加另一个文件夹?
我想以app/assets/fonts同样的方式app/assets/images服务.
更新:5-7-2013
只是为将来发现此问题以明确添加资产路径的人添加一些说明,在application.rb文件中:
config.assets.paths << "#{Rails.root}/app/assets/fonts"
Run Code Online (Sandbox Code Playgroud)
但是,由于上面的路径app/assets不在你明确添加它,你只需要重新启动rails应用程序,这样Sprockets就可以把它拿起来.
你必须明确地添加是外面的路径app/assets,lib/assets或者vendor/assets,只是记得,虽然链轮拿起新的文件夹是存在,当你的应用程序中加载,在我的经验,它不拿起资产路径新的文件夹,而不重启.
我使用以下@font-face声明无法使用我的Rails 3.1应用程序.我把资产管道的字体在其所谓的"字体"自己的文件夹一起images与stylesheets和javascripts
这是我使用的声明(由Font Squirrel生成.)
@font-face {
font-family: 'ChunkFiveRegular';
src: url('Chunkfive-webfont.eot');
src: url('Chunkfive-webfont.eot?#iefix') format('embedded-opentype'),
url('Chunkfive-webfont.woff') format('woff'),
url('Chunkfive-webfont.ttf') format('truetype'),
url('Chunkfive-webfont.svg#ChunkFiveRegular') format('svg');
font-weight: normal;
font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)
有人在他们的Rails 3.1应用程序上成功使用@ font-face吗?
更新
我刚刚阅读了这个主题http://spin.atomicobject.com/2011/09/26/serving-fonts-in-rails-3-1/,它说url要font-url在声明中改变.不幸的是,这似乎没有用.
我正在尝试使用Compass font-face mixin,其中包含
*.eot?iefix
我的app/assets/fonts包含所需的所有字体类型,包括.eot.
当我尝试运行资产时:预编译任务失败说类似:webfont.eot?iefix未预编译
你知道这个问题的可能解决方案吗?
如果我有config.assets.compile = true,它运行时没有错误,但正如我所知,最好不要在生产中使用它.
font-face ruby-on-rails-3.1 sprockets asset-pipeline compass-sass