LoginSignup
6
5

More than 3 years have passed since last update.

Font Awesomeが表示されないときに確認するべきポイント?!【Ruby on Rails】

Posted at

はじめに

「あれっ?!」RailsでHTMLには記述しているのにFont Awesomeが表示されず。。。その解決方法と確認するべきポイントを書きました。

目次

  • gemがインストールされているか確認する
  • htmlが正しく記述できているか確認する
  • application.css.scssファイルを確認する

gemがインストールされているか確認する

Gemfile
gem "font-awesome-rails"

記述していて bundle install できていればOKです。
不安であれば「Gemfile.lock」ファイルを確認してインストールできているか確認します。

htmlが正しく記述できているか確認する

html.erb
<%= fa_icon("home") %>
html.haml
= fa_icon 'home', class: 'icon'

application.css.scssファイルを確認する

私の場合、表示されなかった原因がこれでした。これであっさり解決しました。
以下を追記しました。

application.css.scss
@import " font-awesome ";

おわりに

viewで検証ツールを使って要素はあるのに表示ができていない場合は上記のポイントを確認してみるといいと思います。
より詳しく知りたい方は  font-awesome-rails/GitHub などにも目を通すといいかもしれません。

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5