Skip to content

Commit 30e37be

Browse files
author
ilstar
committed
add config.yml to store app configuration
1 parent 23f2c6d commit 30e37be

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
/tmp
1616

1717
config/database.yml
18+
config/config.yml
1819
*.swp
1920
public/assets/
2021

config/application.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
require "sprockets/railtie"
1010
# require "rails/test_unit/railtie"
1111

12+
$config = {}
13+
config_file = "config/config.yml"
14+
$config = YAML.load_file(config_file)[Rails.env] if File.exists?(config_file)
15+
1216
if defined?(Bundler)
1317
# If you precompile assets before deploying to production, use this line
1418
Bundler.require(*Rails.groups(:assets => %w(development test)))
@@ -79,8 +83,8 @@ class Application < Rails::Application
7983
port: 587,
8084
authentication: "plain",
8185
enable_starttls_auto: true,
82-
user_name: ENV["OFLUNCH_GMAIL_USERNAME"],
83-
password: ENV["OFLUNCH_GMAIL_PASSWORD"]
86+
user_name: $config['mail_username'],
87+
password: $config['mail_password'],
8488
}
8589
config.action_mailer.default_url_options = { host: "10.64.17.47" }
8690
end

config/config.yml.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
common: &common
2+
mail_username: hello
3+
mail_password: world
4+
5+
production:
6+
<<: *common
7+
development:
8+
<<: *common

0 commit comments

Comments
 (0)