前置き
タイトルママ
ralisのDBはデフォルトだとsqliteが使われてるので変更が少し面倒でした。
方法
①posgresqlをインストールする
$ brew install posgresql
$ pg_ctl -D /usr/local/var/postgres start #起動する
$ psql -l #DBのリストが表示されたら成功です
②railsの設定
$ rails new pg_app -D posgresql # rails newのオプションでDBをあらかじめ選択しておく
$ bundle install
③DB初期化
rake db:create
rake db:migrate # これで完了!
補足
Macだと①のpsql -l
でリストがうまく表示できないことがある。
これはMacにデフォルトでインストールされているposgresqlが邪魔になっているのが理由らしい。
その場合は、修正batchを用いて
$ cd /usr/local/Cellar/postgresql
$ curl -o fixBrewLionPostgresql.sh http://nextmarvel.net/blog/downloads/fixBrewLionPostgres.sh
$ chmod 777 fixBrewLionPostgresql.sh
$ ./fixBrewLionPostgresql.sh
これを流した後に、
$ pg_ctl -D /usr/local/var/postgres restart #再起動してあげる
で、繋がる(はず)
参考
http://taise.hatenablog.com/entry/2013/10/13/162546
http://kgmx.hatenablog.com/entry/2014/04/08/085425