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
 MAIL_FROM_ADDRESS=
4
 MAIL_FROM_ADDRESS=
5
 
5
 
6
 AARDBEI_HOSTNAME=
6
 AARDBEI_HOSTNAME=
7
+
8
+RAILS_ENV=
9
+
10
+DB_NAME=
11
+DB_USER=
12
+DB_PASS=

+ 8 - 2
Gemfile

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

+ 2 - 0
Gemfile.lock

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

+ 3 - 1
app/controllers/members_controller.rb

62
 
62
 
63
     respond_to do |format|
63
     respond_to do |format|
64
       format.html do
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
         flash_message(
68
         flash_message(
67
           :success,
69
           :success,
68
           "#{@person.full_name} #{invited}added to group."
70
           "#{@person.full_name} #{invited}added to group."

+ 6 - 2
config/database.yml

21
   database: db/test.sqlite3
21
   database: db/test.sqlite3
22
 
22
 
23
 production:
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