2013年7月31日水曜日

railsアプリをherokuにデプロイしてみる

【目的】
railsアプリローカルで作成後、herokuにデプロイする

【環境】
Rails 3.2.13
ruby 1.9.3
MacOSX Mountain Lion

----------
ターミナル
----------
$ rails new [アプリ名]
$ cd [アプリ名]
$ git init
$ git add .
$ git commit -m "[コメント]"

----------
/config/environments/production.rbを変更
----------
(- ) config.assets.compile = false
(+) config.assets.compile = true  #false=>trueに変更

----------
/Gemfileを変更
----------
(- ) gem 'sqlite3'
(+) gem 'sqlite3', :group => [:development, :test]
(+) group :production do
(+) gem 'pg'
(+) end

----
post controllerを作成
----
$ rails generate controller post index

----
/config/routes.rb編集
----
(+) root :to => 'post#index', as: 'post'

----------
ターミナル
----------
$ rake assets:precompile  #precompileしないと、変更が適用されない
$ heroku create [Heroku上のアプリ名]  #herokuにログインしている必要あり
$ git commit -am "[コメント]"
$ git push heroku master
$ heroku open


以上

0 件のコメント:

コメントを投稿