1.

Rubyのバージョン確認

$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]

Railsのバージョン確認

$ rails -v
Rails 3.2.3

参考: 【番外編】Ruby on Railsでのアプリ開発の基本 – Facebook開発者の為のサポートサイト | fb.developers’+
http://fb.dev-plus.jp/column1/column1_ruby/

 

2.

LionのデフォルトのRubyは1.8.7 なので、
1.9.3を使うために、RVMをインストール。

$ git clone --depth 1 git://github.com/wayneeseguin/rvm.git
$ cd rvm
$ ./install

 

3.

RVMを使うために、~/.bashrc に追記。

$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bashrc

設定が完了したら、「$ source ~/.bashrc」か 再ログイン で設定を読み込む。

$ rvm -v
rvm 1.13.0 () by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

 

4.

1.9.3をインストール

$ rvm install 1.9.3

インストールされているバージョンの一覧

$ rvm list

1.9.3を使用

$ rvm use 1.9.3

1.9.3を初期設定に

$ rvm --default 1.9.3

改めて、$ rvm list の結果

rvm rubies

ruby-1.9.2-p320 [ x86_64 ]
=* ruby-1.9.3-p194 [ x86_64 ]
# => - current
# =* - current && default
#  * - default

参考: Mac に rvm をインストールして 複数バージョンの Ruby を使う – hogehoge foobar Blog Style5
http://d.hatena.ne.jp/mrgoofy33/20110518/1305649544

 

5.

その他、必要に応じて…

gemのインストール

$ sudo port install rb-rubygems

railsのインストール

$ gem install rails

バージョンの確認

$ rails -v

 

6.

Railsアプリを作る場所へ移動

$ cd

アプリ「myapp」を作成

$ rails new myapp

アプリの中に移動

$ cd myapp

Herokuで動かすために「myapp/Gemfile」のgem ‘sqlite3’ を

group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
[code]

に書き換える。

ローカル環境の再インストール
$ bundle install

参考: Rails 3.1 を Heroku (Cedar) にデプロイする – Rails 3.0 on Heroku Bamboo からの変更点 : : lefthandz.org
<a href="http://aws.lefthandz.org/wordpress/2012/01/deploy-rails-3-1-on-heroku-cedar/ " target="_blank">http://aws.lefthandz.org/wordpress/2012/01/deploy-rails-3-1-on-heroku-cedar/</a>

&nbsp;

7.

データベースのテーブル作成

[code]
$ rails g scaffold note body:text title:string
$ rake db:migrate

ローカルのRailsを起動

$ rails s

http://localhost:3000/notes をチェック

 

8.

Herokuにログイン

$ heroku login

※パスワードを毎回聞かれなくするには
公開鍵/秘密鍵の設定

$ heroku keys:add

参考: Ruby1.9.3 + Rails3.2.1セットアップ – I can’t change the world.
http://change-the-world.heroku.com/19

 

9.

Gitの管理下に

$ git init
$ git add .
$ git commit -m "init"

Heroku上にアプリを作成

$ heroku create --stack cedar
or
$ heroku create --stack cedar アプリ名

Herokuにリリース

$ git push heroku master
$ heroku rake db:migrate
$ heroku open

http://アプリ名.herokuapp.com/notes で確認