ToTenMilan
ToTenMilan

Reputation: 640

@import 'font-awesome' doesn't work in Rails

I'm trying to:

@import "font-awesome-sprockets";
@import "font-awesome";

at the end of my application.css.scss file.

First with instructions provided by fontawesome website, then as in this stackoverflow topic

then as in this github topic

None of the solutions worked for me.

My gemfile:

source 'https://rubygems.org'
gem 'rails'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0.4'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'font-awesome-sass', '~> 4.4.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
  gem 'byebug'
end
group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
end

My application.html.erb head section:

<head>
  <title>Grzegorz Milanowski - Personal Website</title>
    <link href='https://fonts.googleapis.com/css?family=Raleway:400,700,800' rel='stylesheet' type='text/css'>
          <!--<link rel="stylesheet" href="font-awesome-4.6.3/css/font-awesome.min.css">-->
    <link rel="stylesheet" href="css/application.css">
    <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    <%= csrf_meta_tags %>
</head>

Error:

Sass::SyntaxError in Welcome#index
Showing /home/ubuntu/workspace/app/views/layouts/application.html.erb where line #8 raised:

File to import not found or unreadable: font-awesome-sprockets.
Load paths:
  /home/ubuntu/workspace/app/assets/images
  /home/ubuntu/workspace/app/assets/javascripts
  /home/ubuntu/workspace/app/assets/stylesheets
  /home/ubuntu/workspace/vendor/assets/javascripts
  /home/ubuntu/workspace/vendor/assets/stylesheets
  /usr/local/rvm/gems/ruby-2.3.0/gems/jquery-rails-4.1.1/vendor/assets/javascripts
  /usr/local/rvm/gems/ruby-2.3.0/gems/coffee-rails-4.1.1/lib/assets/javascripts
  /usr/local/rvm/gems/ruby-2.3.0/gems/turbolinks-source-5.0.0/lib/assets/javascripts
Extracted source (around line #329):
327
328
329
330

}

@import 'font-awesome-sprockets';
@import 'font-awesome';

I will appreciate any help. Let me know if some more logs are needed.

Upvotes: 1

Views: 4351

Answers (1)

hgsongra
hgsongra

Reputation: 1484

Seems after adding gem 'font-awesome-sass', '~> 4.4.0' to Gemfile you forgot to bundle install, do bundle install it will fix your issue

Note: no need of <link rel="stylesheet" href="css/application.css"> you can remove it.

Upvotes: 1

Related Questions