agilecreativity / rails4-spike-template

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

My Rails 4.0 and Postgres Template (for quick spike)

This is my minimal template that I use for spike new idea using Rails 4 and Postgres.

Requirements:

  • Postgres database with admin user postgres
# connect to `postgres` database as `postgres` user (admin)
sudo su - postgres psql postgres
  • Useful command from inside psql session
\?  - list help
\l  - list all databases
\dg - list all roles
  • From inside psql session try to create the role for our app
postgres=# drop database if exists blogs_development;
postgres=# drop database if exists blogs_test;
  • Create a user (or role) blogs_admin with password password with superuser access.
create role blogs_admin with superuser createdb createrole inherit replication login password 'password'
  • Update the database configuration of rails project
development:
  adapter: postgresql
  encoding: unicode
  database: blogs_development
  pool: 5
  username: blogs_admin
  password: password

test:
  adapter: postgresql
  encoding: unicode
  database: blogs_test
  pool: 5
  username: blogs_admin
  password: password

production:
  adapter: postgresql
  encoding: unicode
  database: blogs_production
  pool: 5
  username: blogs_admin
  password: password
  • Run the migration
bundle exec rake db:setup
bundle exec rake db:migrate
  • start the rails console
rails s
  • open your browser to http://localhost:3000 to see the apps

TODO:

  • add starter gems for rspec, guard, or spring, pry, etc.

Useful links

http://www.postgresql.org/docs/9.1/static/sql-createrole.html

About


Languages

Language:Ruby 92.5%Language:JavaScript 4.1%Language:CSS 3.4%