How can I create a Postgres user and database when creating a new rails application?

I carefully studied this useful tutorial:

http://blog.willj.net/2011/05/31/setting-up-postgresql-for-ruby-on-rails-development-on-os-x/

I would really like to start rails new myappand configure postgres db automatically. Is there a way I can do it using a Rails application template or something similar?

+5
source share
2 answers

On a unix based system:

sudo -u postgres createuser -d -R -P APPNAME
sudo -u postgres createdb -O APPNAME APPNAME

You can create a script and put it somewhere in your $ PATH if you cannot remember.

+14
source

, rails.

, , username database.yml

development:
  adapter: postgresql
  encoding: unicode
  database: newapp_development
  pool: 5
  username: #your username
  password:
...

:

rake db:create:all
+8

All Articles