ruby 1.9.3 + rails 3.2.14 + mongoid 3.1.4 + twitter bootstrap + bootswitch + kaminariでアプリ作ってみる by windows

まだちょっとruby 2.0.0 + rails 4.0.0は早いかと思い
ruby 1.9.3 + rails 3.2.14 + mongoid 3.1.4 + twitter bootstrap + bootswitch + kaminariで
まずバージョン指定&active recordスキップでrails作成

rails _3.2.14_ new hogehoge -O

Gemfileに以下を追加
(windowsではtherubyracerでエラーになるので以前書いたエントリーの方法で回避gem 'twitter-bootstrap-rails'でtherubyracerのエラーを回避する by windows - shoprevのブログ

ruby '1.9.3'
gem "mongoid", "~> 3.1.4"
gem 'kaminari'
gem "less-rails"
gem 'twitter-bootstrap-rails'
gem 'twitter_bootstrap_form_for'
if RUBY_PLATFORM =~ /mingw/
  gem 'therubyracer', :path => 'therubyracer-0.11.0beta1-x86-mingw32'
else
  gem 'therubyracer', :platforms => :ruby
end

bootstrap&mongoidインストール

bundle install
bundle exec rails g bootstrap:install less
bundle exec rails g bootstrap:layout application fluid
bundle exec rails g mongoid:config

bootswatchインストール(bootswatchフォルダにサイトからダウンロードしたlessファイルを配置)

mkdir vendor\assets\stylesheets\bootswatch
vendor\assets\stylesheets\bootswatch\variables.less
vendor\assets\stylesheets\bootswatch\bootswatch.less

app/assets/stylesheets/bootstrap_and_overrides.css.lessファイルに以下を追記

@import "bootswatch/variables.less";
@import "bootswatch/bootswatch.less";

config/mongoid.ymlファイル編集(mongolab使用)

development:
  sessions:
    default:
      username: xxxx
      password: xxxx
      database: xxxx
      hosts: 
        - dsxxxx.mongolab.com:xxxx

scaffold作成

bundle exec rails g scaffold Post title:string description:text
bundle exec rails g bootstrap:themed Posts

config/routes.rbファイル編集&/public/index.htmlファイル削除

root to: 'posts#index'

サーバー起動

bundle exec rails s

localhost:3000にアクセスしたらエラー

undefined method `created_at' for #<Article:0x377c520>

自動でcreated_at作られないようなので削除したら
いけたー簡単ー
ちなみにkaminariのレイアウトはコマンド一発で変わったすごい

bundle exec rails g kaminari:views bootstrap

参考
Ruby - twitter-bootstrap-railsでbootswatchを使う - Qiita [キータ]
seyhunak/twitter-bootstrap-rails · GitHub
Mongoid: Installation