Failed to load resource: 404 (not found) - custom Rails fonts

I am trying to load some custom fonts using CSS @font-face. I am using the rails method fonts_path. It successfully generates the correct path in my development browser:

/assets/fonts/my_font.eot?#iefix

However, he adds this path to 0.0.0.0:3000(the rails Development server), which may not be the location of / assets / fonts / in my Rails project. I don't know the relationship between the routes that Rails routes and things like Rails.

Here is the error:

Failed to load resource: the server responded with a status of 404 (Not Found)    http://0.0.0.0:3000/assets/fonts/my_Ffent.woff

Here is my stylesheet:

<style type="text/css">
@font-face{
  font-family:"My Font";
  src:url(<%=font_path('/assets/fonts/my_font.eot?#iefix')%>);
  src:url(<%=font_path('/assets/fonts/my_font.eot?#iefix')%>) format("eot"),url(<%=font_path('/assets/fonts/my_font.woff')%>) format("woff"),url(<%=font_path('/assets/fonts/my_font.ttf')%>) format("truetype"),url(<%=font_path('/assets/fonts/my_font.svg#c1b10d74-5304-41c3-b9de-00f29187df91')%>) format("svg");
}
</style>

The stylesheet is in application.html.erb, which might be part of the problem? It is defined in the tag <head>.

+4

All Articles