Setup twitter-bootstrap-rails
前回の引き続きでTwitter-bootstrap-railsを試す
またこちらのブログを参考にさせてもらう
Twitter-bootstrap-railsのセットアップ
-
Gemfileにtwitter-bootstrap-railsを追加group :assets do ... gem 'twitter-bootstrap-rails' ... end -
インストール
$ bundle install -
追加されたgenerator
$ bundle exec rails g -h ... Bootstrap: bootstrap:install bootstrap:layout bootstrap:themed ... -
初期設定
$ bundle exec rails g bootstrap:install insert app/assets/javascripts/application.js create app/assets/javascripts/bootstrap.js.coffee create app/assets/stylesheets/bootstrap_and_overrides.css.less gsub app/assets/stylesheets/application.css gsub app/assets/stylesheets/application.css
Railsのもろもろの設定
-
controllerの作成
$ bundle exec rails g controller Pages index -
config/routes.rbにroutingを設定... root :to => 'pages#index' ... -
index.html削除$ rm -f public/index.html
Twitter-bootstrap-railsのlayout
-
layout作成
$ bundle exec rails g bootstrap:layout bootstrap fluid create app/views/layouts/bootstrap.html.erb -
layoutの変更
app/views/layouts/bootstrap.html.erbにlayoutを指定class ApplicationController < ActionController::Base layout 'bootstrap' protect_from_forgery end -
railsを起動
$ bundle exec rails s