wechat_config = {} begin config = Rails.application.config_for(:configuration) wechat_config = config['wechat'] raise 'wechat config missing' if wechat_config.blank? rescue => ex raise ex if Rails.env.production? puts %Q{\033[33m [warning] wechat config or configuration.yml missing, please add it or execute 'cp config/configuration.yml.example config/configuration.yml' \033[0m} wechat_config = {} end Util::Wechat.appid = wechat_config['appid'] Util::Wechat.secret = wechat_config['secret']