6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

HerokuでのRuby on Rails メモメモ

Last updated at Posted at 2016-02-13

Herokuって

Salesforceが提供している無料で使えるPaaS環境

Railsアプリケーションの作成

rails new test_app

アプリで用いるプラグインの編集

ローカル環境では,sqlite3を使用し,HerokuではPostgreSQLを使う設定にGemfileを変更.Herokuではsqlite3が使えないため.

・・・
group :development, :test do
  ・・・
  gem 'sqlite3'
end
・・・
group :production do
  gem 'pg'
end

プラグインのインストール

bundle install

Gitの設定

リポジトリの作成

git init

ステージする(次回コミット対象にする)

git add .

コミットする

git commit -m "Initialize repository"

GitHubの設定

Githubをoriginという名前でpush先に指定

git remote add origin git@github.com:YusukeHarada/test_app.git

GitHubにpushする

git push

Herokuの設定

Herokuへアプリケーションの登録

heroku create

Herokuへのpush

git push heroku master

scaffoldを使ったアプリケーション作成

UserデータのCRUDアプリケーションを作成する.

rails generate scaffold name:string email:string

マイグレーションしてDBを作成する

rake db:migrate

変更ファイルをステージする

もしローカル環境で実行したい場合は,
# rails serverで実行可能.

git add .

コミットする

git commit -m "Create application"

GitHubへプッシュ

git push

Herokuにプッシュ

git push heroku master

Herokuのアプリケーションをマイグレーション

heroku run rake db:migrate

アップロードしたアプリケーションを開く

heroku open
6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?