Reputation: 19486
I don't want to place it in the code in situ where it is to be used; how/where should it be defined normally?
I want the connection to be accessible from all over the application, as follows:
connection = Fog::Storage.new({
:provider => 'AWS',
:aws_secret_access_key => YOUR_SECRET_ACCESS_KEY,
:aws_access_key_id => YOUR_SECRET_ACCESS_KEY_ID
})
(from http://fog.io/1.0.0/about/getting_started.html)
Upvotes: 0
Views: 1329
Reputation: 9148
You could set up a constant in an initializer.
config/initializers/fog.rb
FOG_CONNECTION = Fog::Storage.new({
:provider => 'AWS',
:aws_secret_access_key => YOUR_SECRET_ACCESS_KEY,
:aws_access_key_id => YOUR_SECRET_ACCESS_KEY_ID
})
This will then be available within your application as FOG_CONNECTION.directories.get(...)
.
Upvotes: 2