E L Rayle
E L Rayle

Reputation: 1201

Rails Engine - File to import not found or unreadable: font-awesome

I did a super simple rails app and used font-awesome with no problem. Expanding this to do the same steps in a rails engine produces the following error.

File to import not found or unreadable: font-awesome

I am unable to find a solution. If anyone has suggestions on how to make this simple rails engine work with font-awesome, I would be most appreciative.

Steps to generate the rails engine and setup font-awesome...

create the basic engine with one model class for testing

rails plugin new testeng --full --mountable 
cd testeng
bundle install
rails g scaffold book title:string desc:string
rake db:migrate

add in font-awesome

edit testeng.gemspec and add sass-rails and font-awesome gems after the rails gem is included

  s.add_dependency 'sass-rails', '~> 4.0.3'
  s.add_dependency 'font-awesome-rails'

rename application.css to application.css.scss

cd app/assets/stylesheets/testeng/
mv application.css application.css.scss

edit app/assets/stylesheets/testeng/application.css.scss and append import statement at end of file.

@import 'font-awesome';

edit app/views/testeng/books/index.html.erb and use some font-awesome icons

<h1>Listing books</h1>

<%= link_to content_tag(:i, '', :class => "fa fa-plus-circle"), new_book_path  %>

start rails server

cd <root-app-path>
bundle install
cd test/dummy
bundle install
rails s

Test in browser

http://localhost:3000/testeng/books

Get ERROR

File to import not found or unreadable: font-awesome

Upvotes: 8

Views: 11451

Answers (3)

Aditya Kumar
Aditya Kumar

Reputation: 21

I restarted the server and everything worked fine. Try restarting server

Upvotes: 1

z atef
z atef

Reputation: 7679

I had this issue , with the below message :

Sass::SyntaxError at /
File to import not found or unreadable: font-awesome-sprockets.
Load paths:
  /home/user/shop_app/depot2/app/assets/images
  /home/user/shop_app/depot2/app/assets/javascripts

And fixed it by updating the gem to include the version :

changed from:

 gem 'font-awesome-sass'

to:

gem 'font-awesome-sass', '~> 4.4.0'

Upvotes: 4

hermiti
hermiti

Reputation: 496

Install font-awesome-sass instead:

gem 'font-awesome-sass', '~> 4.4.0'

Bundle it:

bundle install

Add the following to your application.css.scss (app/assets/stylesheets):

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

As a test you can add the following line to your view to see if it works:

<%= icon('thumbs-up', 'It Worked!!!', id: 'my-icon', class: 'fa-5x') %>

Upvotes: 3

Related Questions