Rails3.2とRuby1.9.3-p125でheroku
前提
heroku上に今までに構築に失敗したゴミアプリがある場合は
すべて削除から実行すること
ruby1.9.3-p125とrvmなどはインストール済であることが前提
そのあたりはこの辺を参考に。
開発環境構築 - pandazx's blog
上記記事の後半はうまくいっていないので、
rvmを使ってrubyをインストールするところまでを参考にして欲しい。
本題
DBはローカルではSQLite、heroku上ではPostgreSQLを使う設定になっている
以下は構築するための command memo
rvm --create 1.9.3-p125@heroku-sample
gem install heroku --no-ri --no-rdoc
heroku login
gem install rails --version 3.2.2 --no-ri --no-rdoc
rails new heroku-sample -d mysql
rails new heroku-sample
cd heroku-sample
git init
git add -A
git commit -m'init'
curl https://raw.github.com/gist/1970532/376b6a26ed936ac43cad0b17a64512f5c0216a50/Gemifile > Gemfile
rm -f Gemfile.lock
bundle install --without production
git add -A
git commit -m'update gemfile'
mv public/index.html public/___index.html
sed -i -e "s/ # root :to => 'welcome#index'/ root :to => 'top#index'/" config/routes.rb
rails g scaffold item name:string body:text price:integer
rails g controller top index
rake db:migrate
git add -A
git commit -m'generate scaffold and db:migrate'
heroku create --stack cedar proto2
heroku labs:enable user_env_compile
heroku config:add RUBY_VERSION=ruby-1.9.3-p125
git push heroku master
heroku run rake db:migrate --app proto2
heroku open
# command memo
heroku info --app myapp
heroku config
heroku logs
rvm gemset list
rvm gemset delete name
途中、githubからGemfileをダウンロードしているが、それは以下のサイトを参考にしている。
macを買って、今すぐherokuでruby1.9.3 + rails3.2しよう! - ppworks blog