Browse Source

Add support for postgres

Maarten van den Berg 7 years ago
parent
commit
3fdc27a33c
5 changed files with 25 additions and 5 deletions
  1. 6 0
      .rbenv-vars-sample
  2. 8 2
      Gemfile
  3. 2 0
      Gemfile.lock
  4. 3 1
      app/controllers/members_controller.rb
  5. 6 2
      config/database.yml

+ 6 - 0
.rbenv-vars-sample

@@ -4,3 +4,9 @@ MAILGUN_API_KEY=
4 4
 MAIL_FROM_ADDRESS=
5 5
 
6 6
 AARDBEI_HOSTNAME=
7
+
8
+RAILS_ENV=
9
+
10
+DB_NAME=
11
+DB_USER=
12
+DB_PASS=

+ 8 - 2
Gemfile

@@ -3,8 +3,6 @@ source 'https://rubygems.org'
3 3
 
4 4
 # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5 5
 gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
6
-# Use sqlite3 as the database for Active Record
7
-gem 'sqlite3'
8 6
 # Use Puma as the app server
9 7
 gem 'puma', '~> 3.0'
10 8
 # Use SCSS for stylesheets
@@ -58,6 +56,9 @@ group :development, :test do
58 56
 end
59 57
 
60 58
 group :development do
59
+  # Use sqlite3 as the database for development
60
+  gem 'sqlite3'
61
+
61 62
   # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
62 63
   gem 'web-console'
63 64
   gem 'listen', '~> 3.0.5'
@@ -66,5 +67,10 @@ group :development do
66 67
   gem 'spring-watcher-listen', '~> 2.0.0'
67 68
 end
68 69
 
70
+group :production do
71
+  # Use a real database in production
72
+  gem 'pg'
73
+end
74
+
69 75
 # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
70 76
 gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

+ 2 - 0
Gemfile.lock

@@ -102,6 +102,7 @@ GEM
102 102
     nio4r (2.0.0)
103 103
     nokogiri (1.7.1)
104 104
       mini_portile2 (~> 2.1.0)
105
+    pg (0.20.0)
105 106
     puma (3.8.2)
106 107
     rack (2.0.1)
107 108
     rack-test (0.6.3)
@@ -198,6 +199,7 @@ DEPENDENCIES
198 199
   jquery-rails
199 200
   listen (~> 3.0.5)
200 201
   mailgun_rails
202
+  pg
201 203
   puma (~> 3.0)
202 204
   rails (~> 5.0.0, >= 5.0.0.1)
203 205
   sass-rails (~> 5.0)

+ 3 - 1
app/controllers/members_controller.rb

@@ -62,7 +62,9 @@ class MembersController < ApplicationController
62 62
 
63 63
     respond_to do |format|
64 64
       format.html do
65
-        invited = "invited to Aardbei and " if new_rec else ""
65
+        invited = ""
66
+        invited = "invited to Aardbei and " if new_rec
67
+
66 68
         flash_message(
67 69
           :success,
68 70
           "#{@person.full_name} #{invited}added to group."

+ 6 - 2
config/database.yml

@@ -21,5 +21,9 @@ test:
21 21
   database: db/test.sqlite3
22 22
 
23 23
 production:
24
-  <<: *default
25
-  database: db/production.sqlite3
24
+  adapter: postgresql
25
+  encoding: unicode
26
+  database: <%= ENV['DB_NAME'] %>
27
+  username: <%= ENV['DB_USER'] %>
28
+  password: <%= ENV['DB_PASS'] %>
29
+  pool: 5