Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Fonts not found Rails (Production ENV)


In development the fonts load correctly from path:

lib/assets/plugins/global/fonts

however in production I get a 404 file not found for fonticon icons.

Note: bootstrap-icons load correctly in production and the paths match in plugins.bundle.css

Is there a place in the settings.yml where the font has to be loaded/listed?


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (4)


In the generated file, the fonts are referenced at url("fonts/something.ttf"). But rails does not know to look there, and thus, does not find them. So it converts the path to "/fonts/something.ttf", which 404s.

We had to explicitly let rails / sprockets know that it could look in that directory to find the font assets:

Rails.application.config.assets.paths < Rails.root.join("lib", "assets", "plugins", "global")

Note: this comment box will not allow me to use the correct syntax for inject. Be sure to use two less than characters



Hi

Glad you have resolved it. Hope that your solution can help others as well.

Thanks



I am using Capistrano gem for Rails production environment. I got it figured out by moving the fonticon.css file to lib/assets/css and changing the file path in the css to and moving the fonts to custom/fonts/fonticon/{all fonts}.

Now icons bundle in asset pipeline as expected in production env.



Hi

Do you mean you build the assets using the gulp --prod option?

Thanks


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(