Skip to content

Commit

Permalink
#268 Add warning for missing Rails.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Sep 2, 2019
1 parent c4155ec commit 665ad9b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/wechat/api_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@ def self.reload_config!
private_class_method def self.resolve_config_file(config_file, env)
return unless File.exist?(config_file)

# rubocop:disable Security/YAMLLoad
raw_data = YAML.load(ERB.new(File.read(config_file)).result)
# rubocop:enable Security/YAMLLoad
begin
# rubocop:disable Security/YAMLLoad
raw_data = YAML.load(ERB.new(File.read(config_file)).result)
# rubocop:enable Security/YAMLLoad
rescue NameError
puts "WARNING: If using 'Rails.application.credentials.wechat_secret!' in wechat.yml, you need run in 'rails c' and access via 'Wechat.api' or gem 'figaro' instead."
end
configs = {}
if env
# Process multiple accounts when env is given
Expand Down

0 comments on commit 665ad9b

Please sign in to comment.