概要
- railsにユーザー認証機能をつけるgemであるdeviseにbootstrapのデザインを適用させる
環境
Rails 5.0.2
ruby ruby 2.2.6p396 (2016-11-15 revision 56800) [x86_64-darwin15]
インストール
gemが公開されているGitHubのURL
https://github.com/hisea/devise-bootstrap-views
Gemfileにgemを追加
Gemfile
# Deviseはすでに導入されているとします。
gem 'devise-bootstrap-views'
インストールします
$ bundle install --path vendor/bundle
deviseにbootstrapのスタイルを適用
以下の文言を追加
application.css
# SASS
*= require devise_bootstrap_views
# LESS
*= require devise_bootstrap_views_less
boostrapに対応したフォームのテンプレートを作成
$ rails g devise:views:bootstrap_templates
サーバーを再起動して確認。
これで簡単にBootstrap3に対応したフォームを作ることができました。