moves ActionMailer config into .env

Robert Whitney 12 ans auparavant
Parent
Commettre
265fe65a83
4 fichiers modifiés avec 19 ajouts et 21 suppressions
  1. 5 1
      .env.example
  2. 6 8
      config/environments/development.rb
  3. 6 8
      config/environments/production.rb
  4. 2 4
      config/environments/test.rb

+ 5 - 1
.env.example

@@ -1 +1,5 @@
1
-APP_SECRET_TOKEN=REPLACE_ME_NOW!
1
+APP_SECRET_TOKEN=REPLACE_ME_NOW!
2
+DOMAIN=localhost:3000
3
+GOOGLE_APPS_DOMAIN=your-domain-here.com
4
+GMAIL_USERNAME=you@gmail.com
5
+GMAIL_PASSWORD=somepassword

+ 6 - 8
config/environments/development.rb

@@ -32,20 +32,18 @@ Huginn::Application.configure do
32 32
   # Expands the lines which load the assets
33 33
   config.assets.debug = true
34 34
 
35
-  DOMAIN = "localhost:3000"
36
-
37
-  config.action_mailer.default_url_options = { :host => DOMAIN }
38
-  config.action_mailer.asset_host = DOMAIN
35
+  config.action_mailer.default_url_options = { :host => ENV['DOMAIN'] }
36
+  config.action_mailer.asset_host = ENV['DOMAIN']
39 37
   config.action_mailer.perform_deliveries = false # Enable when testing!
40 38
   config.action_mailer.raise_delivery_errors = true
41 39
   config.action_mailer.delivery_method = :smtp
42 40
   config.action_mailer.smtp_settings = {
43 41
       address: "smtp.gmail.com",
44 42
       port: 587,
45
-      domain: "your-google-apps-domain.com",
43
+      domain: ENV['GOOGLE_APPS_DOMAIN'],
46 44
       authentication: "plain",
47 45
       enable_starttls_auto: true,
48
-      user_name: "huginn@your-google-apps-domain.com",
49
-      password: "your-password"
46
+      user_name: ENV['GMAIL_USERNAME'],
47
+      password: ENV['GMAIL_PASSWORD']
50 48
   }
51
-end
49
+end

+ 6 - 8
config/environments/production.rb

@@ -62,20 +62,18 @@ Huginn::Application.configure do
62 62
   # with SQLite, MySQL, and PostgreSQL)
63 63
   # config.active_record.auto_explain_threshold_in_seconds = 0.5
64 64
 
65
-  DOMAIN = 'www.yourdomain.com'
66
-
67
-  config.action_mailer.default_url_options = { :host => DOMAIN }
68
-  config.action_mailer.asset_host = DOMAIN
65
+  config.action_mailer.default_url_options = { :host => ENV['DOMAIN'] }
66
+  config.action_mailer.asset_host = ENV['DOMAIN']
69 67
   config.action_mailer.perform_deliveries = true
70 68
   config.action_mailer.raise_delivery_errors = true
71 69
   config.action_mailer.delivery_method = :smtp
72 70
   config.action_mailer.smtp_settings = {
73 71
       address: "smtp.gmail.com",
74 72
       port: 587,
75
-      domain: "your-google-apps-domain.com",
73
+      domain: ENV['GOOGLE_APPS_DOMAIN'],
76 74
       authentication: "plain",
77 75
       enable_starttls_auto: true,
78
-      user_name: "huginn@your-google-apps-domain.com",
79
-      password: "your-password"
76
+      user_name: ENV['GMAIL_USERNAME'],
77
+      password: ENV['GMAIL_PASSWORD']
80 78
   }
81
-end
79
+end

+ 2 - 4
config/environments/test.rb

@@ -37,8 +37,6 @@ Huginn::Application.configure do
37 37
   # Print deprecation notices to the stderr
38 38
   config.active_support.deprecation = :stderr
39 39
 
40
-  DOMAIN = 'test.host'
41
-
42
-  config.action_mailer.default_url_options = { :host => DOMAIN }
40
+  config.action_mailer.default_url_options = { :host => ENV['DOMAIN'] }
43 41
   config.action_mailer.perform_deliveries = true
44
-end
42
+end