Skip to content

Instantly share code, notes, and snippets.

@ychubachi
Last active December 22, 2015 04:58
Show Gist options
  • Save ychubachi/6420420 to your computer and use it in GitHub Desktop.
Save ychubachi/6420420 to your computer and use it in GitHub Desktop.
2013/9/3 rails,Herokuメモ
- vagrantで仮想マシンをアップ
$ vagrant up
-- 3000番ポートのフォワード設定を確認
- 仮想マシンに接続
$ vagrant ssh
win: localhost:2222
$ cd /vagrant/ <- ホストと共有されている
$ mkdir work
$ cd work
新しく作る
$ rails new second_enpit -T
$ cd second_enpit
gitのグローバル設定
$ git config --global user.name "名前"
$ git config --global user.email "電子メール"
$ git config --list
$ git init
$ git add .
$ git status
.gitignoreの確認(railsが勝手に設定してくれている)
英語はちゃんと読みましょう!!
git commitはステージされているファイルに対して行う
$ git commit -m "first commit"
$ git log
$ git remote add origin git@github.com:<ユーザ>/second_enpit.git
$ git remote -v
どこに接続するか確認できる。
$ git push -u origin master
-uは次回以降使わない事(-u: set upstream)
ホストのVagrantfileを編集
config.vm.network :forwarded_port, guest: 80, host: 3000
$ rails server
ホストのブラウザで http://localhost:3000
を見て、Welcome boardが見える事を確認
以下、ゲストOSでrailsでスキャフォルドを作る
$ rails g scaffold Person name:string age:integer
$ rake db:migrate
$ rails dbconsole
sqlite> .table
people schema_migrations
sqlite> .schema people
・・・スキームが見える・・・
config/routes.rb
#root 'welcome#index'
|
root 'people#index'
$ rake routes
app/controllers/people_controller.rbを見る。書き換える。
$ git add .
$ git status
git reset <ファイル名> で、指定したファイルをステージから降ろす事ができる。
$ git commit
$ git status
リモートよりブランチが1個進んでいる事が分かる。
$ git push
ブラウザで確認しましょう。
* Herokuへのデプロイ
$ heroku login
-> ログイン情報を入力
$ heroku keys:add でキーの登録
$ heroku create
git@heroku.com:shelterd-earth-2265.git
Gemfile ファイルの編集
$ bundle install --without production
$ git push heroku master
$ heroku run rake db:migrate
Getting started with Railsの勉強
http://guides.rubyonrails.org/getting_started.html
Herokuの勉強
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment