Skip to content
This repository has been archived by the owner on Nov 21, 2017. It is now read-only.

Commit

Permalink
Shameful massage by bad-tempered man
Browse files Browse the repository at this point in the history
Nasty fix for DB encryption key supply
Horrid fix for #636
  • Loading branch information
yozlet committed May 5, 2015
1 parent 6335fa2 commit a2f9371
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/models/concerns/encryption.rb
@@ -1,10 +1,12 @@
require 'active_support/concern'

module Encryption
module Encryption
extend ActiveSupport::Concern

def key
key_val = Rails.configuration.database_configuration[Rails.env]['encryption_key']
key_val = ENV.fetch('DB_ENCRYPT_KEY') ||
Rails.configuration.database_configuration[Rails.env]['encryption_key']

# if in production. require key to be set.
if Rails.env.production?
raise 'Must set token key!!' unless key_val
Expand Down
11 changes: 10 additions & 1 deletion lib/two_factor/model_mixin.rb
Expand Up @@ -2,7 +2,16 @@ module TwoFactor
module ActiveRecordMixin
def two_factor(*strategies)
strategies.each do |strategy|
self.include("TwoFactor::Models::#{strategy.to_s.camelize}".constantize)
begin
self.include("TwoFactor::Models::#{strategy.to_s.camelize}".constantize)
rescue NoMethodError
# Yes, this is an awful thing. Glad you noticed.
# Short version: This mixin causes Rails to attempt to reach the DB
# at initialization time, which is a bad thing if you're in the
# compile stage rather than run stage (when trying to build a
# droplet for Cloud Foundry) and you just want to precompile assets.
# Longer discussion: https://github.com/18F/myusa/issues/636
end
end
end
end
Expand Down

0 comments on commit a2f9371

Please sign in to comment.