Skip to content

Instantly share code, notes, and snippets.

@stsysr
Forked from hakobera/rails32_on_heroku_cedar.md
Created March 10, 2012 08:56
Show Gist options
  • Save stsysr/2010889 to your computer and use it in GitHub Desktop.
Save stsysr/2010889 to your computer and use it in GitHub Desktop.
Rails 3.2 on Heroku (cedar)

Rails 3.2 on Heroku (cedar)

環境

  • ruby 1.9.2
  • rails 3.2.1

作成フロー

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

ページアクセス(動作確認)

Gemfile編集

development 環境でのみ sqlite3 を利用

group :development do
  gem 'sqlite3'
end    

production 環境では Heroku の DBを利用

group :production do
  gem 'pg'
end

Gemインストール

bundle install --without production

プリコンパイル

rake assets:precompile

Gitリポジトリ作成

git init

Gitコミット

git add . && git commit -m "first commit"

Gitステータス確認

git status

Herokuアプリ作成

heroku create sample

Herokuプッシュ

git push heroku master

Herokuマイグレーション

heroku run 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

参考URL

http://change-the-world.heroku.com/15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment