[環境]
◆ruby -v
-----
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
-----
◆rails -v
-----
Rails 3.2.1
-----
◆gem -v
1.8.15
◆gem list heroku
-----
*** LOCAL GEMS ***
heroku (2.6.1, 2.5.2, 2.4.0)
-----
----------
[作成フロー]
◆Railsアプリ作成(アプリ名:sampleの場合)
rails new sample
◆ディレクトリ移動
cd sample
◆スキャフォールド作成
rails g scaffold item name:string body:text price:integer
◆コントローラ/ビュー作成
rails g controller top index
◆マイグレーション
rake db:migrate
◆public/index.htmlリネーム
「index.html」=>「_____index.html」
◆ルーティング設定追加
config/routes.rb
-----
root :to => "top#index"
match ':controller(/:action(/:id))(.:format)'
-----
◆サーバ起動
rails s
◆ページアクセス(動作確認)
http://0.0.0.0:3000
http://0.0.0.0:3000/top/index
http://0.0.0.0:3000/items
◆Gemfile編集
-----
group :production do
gem 'pg'
gem 'thin'
# gem 'therubyracer-heroku', '0.8.1.pre3' # you will need this too
end
-----
◆Gemインストール
bundle install --without production
◆プリコンパイル
rake assets:precompile
◆Gitリポジトリ作成
git init
◆Gitコミット
git add . && git commit -m "first commit"
◆Gitステータス確認
git status
-----
# On branch master
nothing to commit (working directory clean)
-----
◆Herokuアプリ作成
heroku create sample
◆Herokuプッシュ
git push heroku master
◆Herokuマイグレーション
heroku rake db:migrate
◆Herokuオープン
heroku open
----------
[更新フロー]
◆プリコンパイル
rake assets:precompile
◆ローカルリポジトリコミット
git add . && git commit -m "update"
◆Herokuデプロイ
git push heroku master
◆Herokuマイグレーション
heroku rake db:migrate
◆Herokuオープン
heroku open