Commit 1ee9e9c

mo khan <mo@mokhan.ca>
2014-04-09 03:48:15
use pg gem.
1 parent 96a2eb4
app/models/user.rb
@@ -1,3 +1,3 @@
-class User
-
+class User < ActiveRecord::Base
+  has_secure_password
 end
config/database.yml
@@ -1,25 +0,0 @@
-# SQLite version 3.x
-#   gem install sqlite3
-#
-#   Ensure the SQLite 3 gem is defined in your Gemfile
-#   gem 'sqlite3'
-development:
-  adapter: sqlite3
-  database: db/development.sqlite3
-  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: sqlite3
-  database: db/test.sqlite3
-  pool: 5
-  timeout: 5000
-
-production:
-  adapter: sqlite3
-  database: db/production.sqlite3
-  pool: 5
-  timeout: 5000
config/database.yml.example
@@ -0,0 +1,15 @@
+development:
+  adapter: postgresql
+  encoding: unicode
+  database: mocode-development
+  pool: 5
+  username: mo
+  password:
+
+test:
+  adapter: postgresql
+  encoding: unicode
+  database: mocode-test
+  pool: 5
+  username: mo
+  password:
db/migrate/20140409034211_create_users.rb
@@ -0,0 +1,8 @@
+class CreateUsers < ActiveRecord::Migration
+  def change
+    create_table :users do |t|
+      t.string :email
+      t.string :password_digest
+    end
+  end
+end
spec/models/user_spec.rb
@@ -0,0 +1,10 @@
+require "spec_helper"
+
+describe User do
+  context "#save" do
+    it "can be saved" do
+      User.create!(email: 'mo@mokhan.ca')
+      User.count.should == 1
+    end
+  end
+end
Gemfile
@@ -3,9 +3,6 @@ source 'https://rubygems.org'
 # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
 gem 'rails', '4.0.4'
 
-# Use sqlite3 as the database for Active Record
-gem 'sqlite3'
-
 # Use SCSS for stylesheets
 gem 'sass-rails', '~> 4.0.2'
 
@@ -36,6 +33,7 @@ end
 gem 'bcrypt', '~> 3.1.7'
 gem 'spank'
 gem 'bootstrap-sass'
+gem 'pg'
 
 # Use unicorn as the app server
 # gem 'unicorn'
@@ -47,4 +45,5 @@ gem 'bootstrap-sass'
 # gem 'debugger', group: [:development, :test]
 group :development, :test do
   gem 'rspec-rails'
+  gem 'debugger'
 end
Gemfile.lock
@@ -38,6 +38,13 @@ GEM
       coffee-script-source
       execjs
     coffee-script-source (1.7.0)
+    columnize (0.3.6)
+    debugger (1.6.6)
+      columnize (>= 0.3.1)
+      debugger-linecache (~> 1.2.0)
+      debugger-ruby_core_source (~> 1.3.2)
+    debugger-linecache (1.2.0)
+    debugger-ruby_core_source (1.3.2)
     diff-lcs (1.2.5)
     erubis (2.7.0)
     execjs (2.0.2)
@@ -56,6 +63,7 @@ GEM
     mime-types (1.25.1)
     minitest (4.7.5)
     multi_json (1.9.2)
+    pg (0.17.1)
     polyglot (0.3.4)
     rack (1.5.2)
     rack-test (0.6.2)
@@ -107,7 +115,6 @@ GEM
       actionpack (>= 3.0)
       activesupport (>= 3.0)
       sprockets (~> 2.8)
-    sqlite3 (1.3.9)
     thor (0.19.1)
     thread_safe (0.3.1)
       atomic (>= 1.1.7, < 2)
@@ -129,13 +136,14 @@ DEPENDENCIES
   bcrypt (~> 3.1.7)
   bootstrap-sass
   coffee-rails (~> 4.0.0)
+  debugger
   jbuilder (~> 1.2)
   jquery-rails
+  pg
   rails (= 4.0.4)
   rspec-rails
   sass-rails (~> 4.0.2)
   sdoc
   spank
-  sqlite3
   turbolinks
   uglifier (>= 1.3.0)