rails + heroku メモ
railsのコマンド関係
新規アプリケーションの作成
rails new apprication_name
コントローラの追加
rails g controller controller_name action1_name action2_name ...
モデルの追加
rails g model model_name column1_name:data_type, column2_name:data_type
コントローラ, モデルの削除
rails d controller ... rails d model ...
dbのmigrate
rake db:migrate
HerokuへのDeploy関係
localとheroku用のgemfileやconfigの設定
gemfileの
gem 'sqlite3'
を
group :production do gem 'pg' gem 'therubyracer-heroku' end group :development, :test do gem 'sqlite3' end
に変更
config/environments/production.rbの
config.assets.compile = false
を
config.assets.compile = true
に変更
config/apprication.rbに
config.assets.initialize_on_precompile = false
を追加
全部やったら
bundle install --without production
しておく
herokuにdeployする
gitの設定
git init
git管理下に追加
git add .
(.gitignoreの条件を満たすもの以外)をgitの対象に追加
コミット
git commit -m "commit"
herokuにアプリケーションを作成
heroku create appricationname
アプリケーション名は全部小文字, アンダースコアは使えない.
gitのremote設定
git remote add heroku git@heroku.com:appricationname.git
herokuにdeploy
git push heroku master
herokuのdbをmigrate
heroku rake db:migrate