Skip to content

Instantly share code, notes, and snippets.

@andrew-h-lee
Last active May 27, 2016 12:22
Show Gist options
  • Select an option

  • Save andrew-h-lee/f455aaf221b2c6941ae42e0b7b9fae82 to your computer and use it in GitHub Desktop.

Select an option

Save andrew-h-lee/f455aaf221b2c6941ae42e0b7b9fae82 to your computer and use it in GitHub Desktop.
Create Rails App w/ PostgreSQL

Instructions: Rails & PostgreSQL

  • Creating a new rails app using postgresql
$ mkdir rails_projects
$ cd rails_projects
$ rails new myapp --database=postgresql
$ cd myapp
  • Run bundle install
$ bundle update
$ bundle install
  • Update the passwords in the config/database.yml file username: myapp password: password

  • Create a user in postgresql $ createuser myapp

  • Create test, development and production databases

$ createdb -Omyapp -Eunicode myapp_development
$ createdb -Omyapp -Eunicode myapp_test
$ createdb -Omyapp -Eunicode myapp_production
  • Test the rails server ```$ rails s````

  • Append the following lines to the Gemfile

# Use rspec as the testing framework
group :development, :test do
  gem 'rspec-rails', '~> 3.0.0.beta'
end
  • Install rspec
$ bundle install
$ rails generate rspec:install

Note: Delete the test folder in rails.

  • Create a binstub for the rspec command $ bundle binstubs rspec-core

  • Check if you can run rspec $ rspec

  • Initialize a git repository $ git init

  • Create a new repository on github and follow the 'create repository' instructions

$ git add .
$ git commit -m "[Setup] first commit"
$ git remote add origin [email protected]:user/myapp.git
$ git push -u origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment