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.
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
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') %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With