Skip to content

Instantly share code, notes, and snippets.

@timurvafin
Last active January 4, 2016 08:59
Show Gist options
  • Save timurvafin/8599286 to your computer and use it in GitHub Desktop.
Save timurvafin/8599286 to your computer and use it in GitHub Desktop.
Rails application configuration
# .env
# Setup sensitive information using .env file
# It should be added to .gitignore
AWS_ACESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
# config/application.rb
# Rails.configuration is the main place to configure application
# If you need to setup some sensitive information like API keys, setup it with ENV
RailsBase::Application.configure do
config.carrierwave.storage = :fog
config.carrierwave.aws_access_key_id = ENV['AWS_ACESS_KEY_ID']
config.carrierwave.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
end
# config/initializers/carrierwave.rb
# Gem initializers should be configured with Rails.configuration
# They should not access ENV directly
CarrierWave.configure do |config|
config.storage = Rails.configuration.carrierwave.storage
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => Rails.configuration.carrierwave.aws_access_key_id,
:aws_secret_access_key => Rails.configuration.carrierwave.aws_secret_access_key
}
end
gem 'custom_configuration'
gem 'dotenv-rails'
# config/environments/test.rb
# Redefine application configuration using Rails configuration
# file for specific environment
RailsBase::Application.configure do
config.carrierwave.storage = :file
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment