我创建了一个名为oauth.yml的yml文件。我希望它包含在rails应用程序中。我应该把它包括在内。
答案 0 :(得分:6)
您应该将它包含在配置文件夹下:
app/config/oauth.yml
让我们假设您的文件是这样的:
development:
key: some_key
secret: some_secret
test:
key: some_key
secret: some_secret
现在,在rails应用程序中的某个位置,可能在初始化程序文件中(在app / config / initializers下),您将此文件加载到变量或类:
all_oauth_config = YAML.load_file( File.join( Rails.root, 'app', 'config', 'oauth.yml' ) )
current_oauth_config = all_oauth_config[Rails.env]
#now do something with this current_oauth_config variable