0

I am trying to use font-awesome-rails for rails app to load all the fonts instead of manually putting the files required.

For some reason, I put the gem in my Gemfile, and after doing `bundle installs, no files are getting generated in my assets folder and obviously then the fonts are not loading for my app.

What could be the reason for this?

And I did add the *= require font-awesome under application.css

Below is my Gemfile

   source 'https://rubygems.org'
   # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
   gem 'rails', '4.2.0'
   # Use sqlite3 as the database for Active Record

     group :development, :test do
     gem 'sqlite3'
     end

     group :production, :staging do
     gem 'pg'
     gem 'rails_12factor'
     end


     gem "font-awesome-rails"

     # Use SCSS for stylesheets
     gem 'sass-rails', '~> 5.0'
     # Use Uglifier as compressor for JavaScript assets
     gem 'uglifier', '>= 1.3.0'
     # Use CoffeeScript for .coffee assets and views
     gem 'coffee-rails', '~> 4.1.0'
     # See https://github.com/sstephenson/execjs#readme for more  supported runtimes
     # gem 'therubyracer', platforms: :ruby

     # Use jquery as the JavaScript library
     gem 'jquery-rails'
     # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
     gem 'turbolinks'
     # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
     gem 'jbuilder', '~> 2.0'
     # bundle exec rake doc:rails generates the API under doc/api.
     gem 'sdoc', '~> 0.4.0', group: :doc

    # Use ActiveModel has_secure_password
    # gem 'bcrypt', '~> 3.1.7'

     # Use Unicorn as the app server
     # gem 'unicorn'

     # Use Capistrano for deployment
     # gem 'capistrano-rails', group: :development

     group :development, :test do
     # Call 'byebug' anywhere in the code to stop execution and get a debugger console
     gem 'byebug'

    # Access an IRB console on exception pages or by using <%= console %> in views
     gem 'web-console', '~> 2.0'

    # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
     gem 'spring'
     end 

Please help.

Suraj
  • 2,423
  • 12
  • 39
  • 75

1 Answers1

0

I was having same problem and also tried some solutions but at last i came up with this solution. Add this below link tag into your application.html.erb file and try again :

<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">

To check whether it is working or not, add <i class="fa fa-camera-retro fa-lg"></i> into your any view file which might be show camera icon.

rick
  • 1,675
  • 3
  • 15
  • 28
  • As @suraj has already installed the gem..he dont need to use the cdn. – Milind Jun 18 '15 at 10:07
  • @Milind The trouble with gem is, the icons aren't loading, while with CDN it does, So I think CDN is the way for me at the moment – Suraj Jun 18 '15 at 10:08
  • 1
    @Milind Yes. But i was having same problem and i tried many solution but was not able to solve my problem. At the end i have directly added cdn in application.html.erb file. Thanks for your suggestion. – rick Jun 18 '15 at 10:09
  • Now the trouble is, while I try to push the app to heroku, I get this issue.. remote: Sass::SyntaxError: Undefined variable: "$fa-css-prefix". How do I solve this now – Suraj Jun 18 '15 at 10:18
  • @rick Also, not all the fonts are loading with the CDN – Suraj Jun 18 '15 at 10:25
  • I checked you have already asked same question before : http://stackoverflow.com/questions/30862242/not-able-to-push-the-app-to-heroku – rick Jun 18 '15 at 10:29
  • Yes, I am not sure, what is going wrong here.. When I am simply using the gems, the fonts are not loading at all, they are partially loading with the CDN – Suraj Jun 18 '15 at 10:32