65
50

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

gem 'font-awesome-rails'は最新版に対応してない... 代わりにfont-awesome-sassを使おう!

Last updated at Posted at 2018-11-02

久しぶりにfontawesomeをrailsで使う事になり gem 'font-awesome-rails'をインストール
さっそくヘルパーメソッドを使って表示しようとすると一部のアイコンが表示できない。

調べてみると、どうも'font-awesome-rails'は最新版のfont-awesome5に対応していないとの事
https://github.com/bokmann/font-awesome-rails/issues/194

同じissue内で'font-awesome-sass'というgemが勧められていたので早速使ってみる。
https://github.com/FortAwesome/font-awesome-sass

Gemファイル内に記入し、

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

bundleinstall

bundle install

application.scss内に 'font-awesome-sprockets' 'font-awesome'の二つをimport

/application.scss

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

ヘルパーの書き方はfont-awesome-railsと少し違うが

slimで書いてます
= icon 'far', 'file-alt'

これでfontawesome5系のアイコンもrailsで簡単に使えるようになった。

65
50
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
65
50

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?