Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 447
E L Rayle Avatar asked Nov 01 '22 10:11

E L Rayle


1 Answers

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') %>
like image 88
hermiti Avatar answered Nov 02 '22 22:11

hermiti