Rails 制作:导入的 Google 字体未加载

Dav*_*ani 1 css import fonts ruby-on-rails ruby-on-rails-4.2

问题:

看到有关此主题的问题后,我请求您的帮助。

/assets/stylesheets/styles.css: @import url("http://fonts.googleapis.com/css?family=Merriweather");

当我rails stestdevelopment上运行时,加载了字体“Merriweather”,但是当我在生产上运行服务器时,没有加载字体,但加载了styles.css。


我试过的:

•若要将@import url(...)application.csswelcome.scssbootstrap.css.scss

• 更改@import url('http://fonts.google...')@import url('//fonts.google...')

附加信息:

应用程序.css

 *= require_tree .
 *= require_self
 *= require 'styles'
Run Code Online (Sandbox Code Playgroud)

Github:https : //github.com/David-Amrani-Hernandez/MovieReader

feb*_*Ink 5

Have you tried linking directly to the font source in the <head> of your application layout file rather than via a stylesheet?

application.html.erb

<head>
    ...
    <%= stylesheet_link_tag( 'http://fonts.googleapis.com/css?family=Merriweather' ) %>
    ...
</head>
Run Code Online (Sandbox Code Playgroud)

I have used this method in production several times, and it hasn't given me problems. I hope it is the same for you.