xcode-select --install
- brewをインストールする
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- brewがインストールされているかを確認
brew -v
- brewのupdate
brew update
- rbenvのインストール
brew install rbenv ruby-build
- 設定
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
echo 'export PATH="$HOME/.rbenv/shims:$PATH"' >> ~/.bash_profile
- 再読込
source ~/.bash_profile
- インストールの確認
rbenv -v
- Rubyがインストールされているかを確認(大体、入っているはずなので)
ruby -v
- 入ってなかったらインストール
rbenv install 2.3.1
- デフォルトのRubyを設定
rbenv global 2.3.1
- Railsのインストール
gem install rails --no-document
- Railsがインストールされているかを確認
rails -v
- Gitをインストール
brew install git
- Gitがインストールされたかを確認
git version
-
GitHubのアカウント登録
https://github.com/join -
Gitのセットアップ
git config --global user.name "Your Account"
git config --global user.email "Your Email"
- Gitの設定ができたかを確認
git config -l
以下のようになっていればok
user.name=kosukeobata
[email protected]
[sublimeText](https://download.sublimetext.com/Sublime Text Build 3124.dmg)
- ホームディレクトリに移動
cd
- handson用のディレクトリを作成
mkdir -p rails/workspace
- handson用のディレクトリに移動
cd rails/workspace
- railsプロジェクトの作成
rails new biz_handson
- プロジェクトに移動
cd biz_handson
- サーバーを起動してみる。
rails server
-
アクセスしてみる。
http://localhost:3000 -
データベースなどを作成
rails generate scaffold introduction name:string description:text
- DBのmigrationを行う
rake db:migrate
- 作成したページにアクセスし、投稿・閲覧・編集・削除をしてみよう
http://localhost:3000/introductions
- rdocをmdに変更(GitHubがmdのみにしか対応していない為)
mv README.rdoc README.md
- プロジェクトにgitを追加(.gitなどが生成される)
git init
- 新規ファイルを追加するコマンド
git add .
- gitの状態を確認
git status
- コミット
git commit -am "Initial Commit"
- gitの状態を確認(ファイル名がなくなっていればok)
git status
-
GitHub画面で新規リポジトリを作成
https://github.com/new -
remoteとの紐付け
git remote add origin [email protected]:kosukeobata/biz_hanson.git
- GitHubにアップロードする
git push -u origin master
-
Herokuのユーザー登録
https://signup.heroku.com/ -
HerokuToolBeltをインストール
https://s3.amazonaws.com/assets.heroku.com/heroku-toolbelt/heroku-toolbelt.pkg -
Herokuがインストールされたかを確認
heroku version
- Herokuにログイン
heroku login
- 認証鍵を生成
heroku keys:add
- Heroku用にDBを変更
gem 'sqlite3'
↓
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor' -- Rails4の場合
end
- 本番環境の変更を適用
bundle install --without production
- Herokuを作成
heroku create
-
herokuのダッシュボードにappが追加されていることを確認
https://dashboard.heroku.com/apps -
デプロイ
git push heroku master
- HerokuのDBのmigration
heroku run rake db:migrate
- アプリを開く
heroku open
- RailsTutorial
http://railstutorial.jp/ - Rails Girls
http://railsgirls.jp/ - Bootstrap
http://getbootstrap.com/ - FontAwesome
http://fontawesome.io/