railslove / fontello_rails_converter

CLI gem for comfortably working with icon fonts (open, download, convert) from http://fontello.com for usage in Rails apps.
MIT License
73 stars 35 forks source link

Fonts not deploying on Heroku with Rails 4 #7

Closed ChrisSki closed 10 years ago

ChrisSki commented 10 years ago

I tried a number of things that did not work. I ended up with having to move the fonts to my app/assets directory for them to work on Heroku.

Per Heroku, I am using the rails_12factor gem and have config.serve_static_assets = true in production.rb

Any insight into this? Or should this gem be installing the font folder in the app directory?

jhilden commented 10 years ago

@ChrisSki can you check if that commit fixes your issues? 43cba5591371a9f56a56d95a42e8327a3852faf3

I strongly believe that vendor/assets/fonts is the appropiate location for these files, so even though app/assets will work out of the box I wouldn't want to put them there if it isn't stritcly necessary.

It would be great if you could give me some feedback if the change worked for you, then I can release a new version of the gem.

Thanks for the issue report.

dinshaw commented 10 years ago

This was not a heroku issue, for me. Locall, in production mode, with precompiled assets, i had to add

config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/

to application.rb

My icon render from vendor/assets/fonts. Great gem, thank you.

jhilden commented 10 years ago

Glad you like the gem @dinshaw

So is the commit above improving the situation for you or is it a problem in any way?

dinshaw commented 10 years ago

The above line fixes everything for me. After running fontello convert, everything works fine in dev, but the fonts are not in the asset path after a deploy to Heroku. I was able to reproduce locally by running rake assets:precompile RAILS_ENV=production; rails s -e production. The fix above adds the fonts to the compiled assets, and both my scenarios worked perfectly.

paulkoegel commented 10 years ago

@dinshaw, https://github.com/railslove/fontello_rails_converter/commit/43cba5591371a9f56a56d95a42e8327a3852faf3 should fix your problem as it contains the fix you mention. could you try loading the gem with:

gem 'fontello_rails_converter', github: 'railslove/fontello_rails_converter', require: nil

and running bundle update fontello_rails_converter. then it should work on Heroku without having to set

config.assets.precompile << /\.(?:svg|eot|woff|ttf)$/

in application.rb.

dinshaw commented 10 years ago

Tried that and it did not fix the issue. The require: nil in the above gemfile line means the config change will not do anything. If you remove the require: nil, it does work. For my money, i'd rather leave the gem in group :development and add the config line myself. Less magic, less prod gems to worry about down the road.

paulkoegel commented 10 years ago

+1 from me, imho gems shouldn't mess with Rails internals. so revert https://github.com/railslove/fontello_rails_converter/commit/43cba5591371a9f56a56d95a42e8327a3852faf3 and add the config to the readme. what do you think @jhilden?

jhilden commented 10 years ago

I just released a new version of the gem 0.2.0 including the Railtie integration (43cba55). I believe that gems should work out of the box if possible. And this is the only way that we can update this configuratoin if rails should change at some point.

I would however, gladly take a README pull request, telling people they can also add the gem to their :development group and add the necessary production config themselves.

jhilden commented 10 years ago

I'm closing this now. Please let me know if there are any issues left.