Skip to content

Commit f2e210a

Browse files
author
Dave Newman
committed
Get coderwall up and running smoother
This removes dependencies on certain ENV vars, automatically copies the .env.example file to .env and runs the rake tasks using foreman. This should theoretically mean vagrant up just works without any fuss.
1 parent 4189e96 commit f2e210a

File tree

8 files changed

+23
-13
lines changed

8 files changed

+23
-13
lines changed

.env.example

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ MAILGUN_TOKEN=mailgun_token
2020
MIXPANEL_API_SECRET=mixpanel_api_secret
2121
MIXPANEL_TOKEN=mixpanel_token
2222

23-
MONGODB_DATABASE_NAME=coderwall
24-
2523
NOTIFIER_ADMIN_EMAILS="['notifier_admin@example.com']"
2624

2725
PRIVATE_ADMIN_PATH=private_admin_path
@@ -32,7 +30,7 @@ REDIS_URL=redis://localhost:6379
3230
REVIEWERS="['Administrator']"
3331

3432
STRIPE_PUBLISHABLE_KEY=pk_test_stripe_publishable_key
35-
STRIPE_SECRET_KEY=sk_test_stripe_secret_key
33+
STRIPE_SECRET_KEY=sk_test_BQokikJOvBiI2HlWgH4olfQ2
3634

3735
SUPPORT_EMAIL=support@example.com
3836

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.DS_Store
88
.bundle
99
.config
10-
.env
10+
*.env
1111
.idea
1212
.sass-cache
1313
.vagrant

app/controllers/accounts_controller.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def create
1717

1818
@account = @team.build_account(params[:account])
1919
@account.admin_id = current_user.id
20-
@account.trial_end = Date.new(2013, 1, 1).to_time.to_i if session[:discount] == ENV['DISCOUNT_TOKEN']
20+
# TODO: (whatupdave) this doesn't look like it's being used any more. Remove if possible
21+
# @account.trial_end = Date.new(2013, 1, 1).to_time.to_i if session[:discount] == ENV['DISCOUNT_TOKEN']
2122

2223
if @account.save_with_payment(@plan)
2324
unless @team.is_member?(current_user)

app/models/protip.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,13 @@ def already_created_a_protip_for(url)
401401
end
402402

403403
def valid_reviewers
404-
Rails.cache.fetch('valid_protip_reviewers', expires_in: 1.month) { User.where(username: YAML.load(ENV['REVIEWERS'])).all }
404+
Rails.cache.fetch('valid_protip_reviewers', expires_in: 1.month) do
405+
if ENV['REVIEWERS']
406+
User.where(username: YAML.load(ENV['REVIEWERS'])).all
407+
else
408+
[]
409+
end
410+
end
405411
end
406412

407413
end

config/application.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class Application < Rails::Application
3333
config.ember.variant = Rails.env.downcase.to_sym
3434
config.assets.js_compressor = :uglifier
3535

36+
config.logger = Logger.new(STDOUT)
37+
config.logger.level = Logger.const_get(ENV['LOG_LEVEL'] ? ENV['LOG_LEVEL'].upcase : 'INFO')
3638

3739
config.after_initialize do
3840
if %w{development test}.include?(Rails.env)

config/environments/development.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
config.active_support.deprecation = :log
77
config.assets.compile = true
88
config.assets.compress = false
9-
config.assets.debug = true
9+
config.assets.debug = false
1010
config.cache_classes = false
1111
config.consider_all_requests_local = true
1212
config.host = 'localhost:3000'

config/mongoid.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
development:
22
host: localhost
3-
database: <%= ENV['MONGODB_DATABASE_NAME'] %>
4-
# database: badgify_development
3+
database: badgify_development
54

65
test:
76
host: localhost
8-
database: badgiy_test
7+
database: badgify_test
98

109
staging:
1110
uri: <%= ENV['MONGOLAB_URI'] %>

vagrant/user-config.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ cd $HOME/web
2323
gem update --system && gem update bundler
2424
bundle config --global jobs 3
2525
bundle install
26-
bundle exec rake db:create:all
27-
bundle exec rake db:setup
28-
bundle exec rake db:test:prepare
26+
27+
# Setup .env
28+
cp .env.example .env -n
29+
30+
foreman run rake db:create:all
31+
foreman run rake db:setup
32+
foreman run rake db:test:prepare

0 commit comments

Comments
 (0)