Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJacqueline Boltik
Courses Plus Student 11,153 PointsGoogle font not rendering in production (but works locally) in a Ruby on Rails application.
I'm using Ruby 2.1 and Rails 4.1 along with a google font. I used the provided links to my google font in the application.html.erb file in the header section as recommended. The fonts render locally but not after I deploy the application through heroku.
I thought it was working but now stopped, but now I'm not positive it was ever working....
I've tried $ rake assets:precompile $ rake assets:precompile RAILS_ENV=production and removing "//=require tree" from application.js
Any other suggestions?
2 Answers
Maciej Czuchnowski
36,441 PointsFirst try this instead of putting the font in the erb file: http://stackoverflow.com/questions/21084448/rails-production-server-google-font-not-loading
Yeah, I know this problem, although in my case it was the custom font from bootstra386 theme and later, the bootstrap glyphicons. It worked perfectly in development and didn't work in production no matter what I did. The culprit is Rails Asset Pipeline that gives custom names to production assets (it's this way since Rails 4 I think).
If the above solution does not work, I'm not sure how to handle fonts that are downloaded through CDNs, but I can tell you how to handle fonts that you download into your project. This could be helpful if you can download the fonts:
http://anotheruiguy.roughdraft.io/7379570-custom-web-fonts-and-the-rails-asset-pipeline
Jacqueline Boltik
Courses Plus Student 11,153 PointsHeroku doesn't accept 'http://' I kept the link that Google provided for the font in application.html.erb and just got rid of 'http:' and kept everything else the same. Hopefully this will help someone else out since there doesn't seem to be much out there about this issue.
Jacqueline Boltik
Courses Plus Student 11,153 PointsJacqueline Boltik
Courses Plus Student 11,153 PointsThanks for your reply. It seems like what you recommended for downloading the font files locally and adding to the application would have worked. I got off track after I realized downloading the Google font was not entirely straight forward.
I've tried a lot of things - changing the production.rb settings, rake assets:precompile with production and with bundle exec etc and nothing worked.
What ended up working was SO simple. Heroku doesn't accept 'http://' I kept the link that Google provided in application.html.erb and just got rid of http. It works perfectly now.
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsGood to know for future reference :)