title: How do I get my rails app to use my postgresql db?
body: <p>I installed prostgres to use with my rails4 app, and I am able to connect to the database server and create databases. Then I made the necessary changes to my Gemfile and config/database.yml to use postgres.  Then I created a new app, and in the app I created a User model:</p>
  
  <pre><code>$ rails generate model User name:string email:string
        invoke  active_record
        create    db/migrate/20130806145935_create_users.rb
        create    app/models/user.rb
        invoke    rspec
        create      spec/models/user_spec.rb
  </code></pre>
  
  <p>And then I did:</p>
  
  <pre><code>$ bundle exec rake db:migrate
  ==  CreateUsers: migrating ====================================================
  -- create_table(:users)
     -&gt; 0.1498s
  ==  CreateUsers: migrated (0.1500s) ===========================================
  </code></pre>
  
  <p>But in the db directory, I see these files:</p>
  
  <pre><code>development.sqlite3
  test.sqlite3
  </code></pre>
  
  <p>Furthermore, when I try to look at those files with the SQLite Database Browser, I get an error that says they are not sqlite 3 databases. In fact, they are empty:</p>
  
  <pre><code>~/rails_projects/sample_app4_0/db$ ls -al
  total 40
  drwxr-xr-x   8 7stud  staff    272 Aug  6 22:50 .
  drwxr-xr-x  24 7stud  staff    816 Aug  6 22:23 ..
  -rw-r--r--   1 7stud  staff      0 Jul 30 00:21 development.sqlite3
  drwxr-xr-x   3 7stud  staff    102 Aug  6 22:22 migrate
  -rw-r--r--   1 7stud  staff   1063 Aug  6 09:06 schema.rb
  -rw-r--r--   1 7stud  staff    343 Jul 29 20:01 seeds.rb
  -rw-r--r--   1 7stud  staff      0 Jul 30 03:02 test.sqlite3
  </code></pre>
  
  <p>I read that you can create your rails app with a flag that tells it to use postgres:</p>
  
  <pre><code>rails new myapp --database postgresql
  </code></pre>
  
  <p>but I already created my app.  Do I have to start over?  I'm using git if that makes a difference.</p>
  
  <p>My Gemfile:</p>
  
  <pre><code>source 'https://rubygems.org'
  ruby '2.0.0'
  #ruby-gemset=railstutorial_rails_4_0
  
  gem 'rails', '4.0.0'
  gem 'bootstrap-sass', '2.3.2.0'
  #Added for postgres:
  gem 'pg', '0.15.1'
  
  
  group :development, :test do
    #gem 'sqlite3', '1.3.7'
    gem 'rspec-rails', '2.13.1'
    gem 'guard-rspec', '2.5.0'
  
    gem 'spork-rails', github: 'sporkrb/spork-rails'
    gem 'guard-spork', '1.5.0'
    gem 'childprocess', '0.3.6'
  end
  
  group :test do
    gem 'selenium-webdriver', '2.0.0'
    gem 'capybara', '2.1.0'
    gem 'growl', '1.0.3'
  end
  
  gem 'sass-rails', '4.0.0'
  gem 'uglifier', '2.1.1'
  gem 'coffee-rails', '4.0.0'
  gem 'jquery-rails', '2.2.1'
  gem 'turbolinks', '1.1.1'
  gem 'jbuilder', '1.0.2'
  
  group :doc do
    gem 'sdoc', '0.3.20', require: false
  end
  
  group :production do
    #gem 'pg', '0.15.1'
    gem 'rails_12factor', '0.0.2'
  end
  </code></pre>
  
  <p>config/database.yml:</p>
  
  <pre><code>development:
    adapter: postgresql
    encoding: utf8
    database: sampleapp_dev  #can be anything unique
  
    pool: 5
    timeout: 5000
  
  # Warning: The database defined as "test" will be erased and
  # re-generated from your development database when you run "rake".
  # Do not set this db to the same as development or production.
  
  test:
    adapter: postgresql
    encoding: utf8
    database: sampleapp_test  #can be anything unique
  
    pool: 5
    timeout: 5000
  
  production:
    adapter: postgresql
    database: sampleapp_prod 
  
    pool: 5
    timeout: 5000
  </code></pre>