2009年8月22日土曜日

Rails on heroku

heroku.com上でRailsAppをdeployしたときのメモ

環境:
MacOSX 10.5.8
ruby 1.8.7 (2008-08-11 patchlevel 72)
rails 2.3.3
heroku-gem/1.1

手順:
localでdevelop

$ rails heroku
$ cd heroku
$ ./script/generate i18n_scaffold status content:text
$ rake db:migrate

*localでdbのmigrateして、deploy時に必要に応じてdb:pushする

$ ./script/generate i18n ja
$ cat config/environment.rb
config.time_zone = 'Tokyo'
config.i18n.default_locale = 'ja'

*i18n化 http://rails-i18n.org/wiki/wikipages/i18n-rails-guide


$ ./script/plugin install git://github.com/technoweenie/restful-authentication.git
$ mv vendor/plugins/restful-authentication/ vendor/plugins/restful_authentication/

>IMPORTANT FOR RAILS > 2.1 USERS To avoid a NameError exception (lighthouse tracker ticket), check out the code to have an underscore and not dash in its name:
*restful_authenticationはrenameが必要(?)のため、vendor/pluginsにinstall。他のはheroku上でinstallする。

$ ./script/generate authenticated user sessions
$ cat app/controllers/application_controller.rb
include AuthenticatedSystem
$ rake db:migrate

*restful_authenticationのためのmigrate

$ vi config.environment.rb
config.gem "searchlogic"
config.gem "will_paginate"
config.gem "jpmobile"

*localでは他のpluginはsudo gem installでインストールしておく


$ cat .gems
searchlogic
will_paginate
jpmobile

*.gemsにheroku上でのmanifestを書いておく。
herokuのplatform上に既にインストールされているgemsはhttp://installed-gems.heroku.com/

で、いろいろ開発して、git&heroku


$ heroku create appname
$ heroku info --app appname

*gitアカウント作成、キー登録後に、appの作成

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


$ git remote add heroku git@heroku.com:appname.git
$ git push heroku master

*git remoteリポジトリにherokuを登録し、masterブランチにpush


$ heroku db:push

*必要に応じて、delopmentDBをdeployのherokuにpush。もしくはheroku rake db:migrateか?

$ heroku restart

*app serverのリスタート