Skip to content

Commit

Permalink
use Figaro to read ENV variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Devin Zhang committed Jun 7, 2013
1 parent 1031545 commit 6efad4b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def init
initialize_breadcrumbs_and_title

@seo_description = ''
ActionMailer::Base.default_url_options[:host] = ENV['RABEL_HOST_NAME']
ActionMailer::Base.default_url_options[:host] = Figaro.env['RABEL_HOST_NAME']
end

def initialize_breadcrumbs_and_title
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/upyun_images_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class UpyunImagesController < ApplicationController
before_filter :authenticate_user!

def create
redirect_to root_path if ENV['RABEL_UPYUN_SWITCH'] != 'on'
redirect_to root_path if Figaro.env['RABEL_UPYUN_SWITCH'] != 'on'

respond_to do |f|
f.json {
Expand Down
8 changes: 4 additions & 4 deletions app/uploaders/upyun_image_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class UpyunImageUploader < CarrierWave::Uploader::Base
# storage :fog
storage :upyun

self.upyun_username = ENV['RABEL_UPYUN_OP_NAME']
self.upyun_password = ENV['RABEL_UPYUN_OP_PASSWORD']
self.upyun_bucket = ENV['RABEL_UPYUN_BUCKET']
self.upyun_bucket_domain = ENV['RABEL_UPYUN_BUCKET_DOMAIN']
self.upyun_username = Figaro.env['RABEL_UPYUN_OP_NAME']
self.upyun_password = Figaro.env['RABEL_UPYUN_OP_PASSWORD']
self.upyun_bucket = Figaro.env['RABEL_UPYUN_BUCKET']
self.upyun_bucket_domain = Figaro.env['RABEL_UPYUN_BUCKET_DOMAIN']

process :resize_to_limit => [570, 0]

Expand Down
3 changes: 3 additions & 0 deletions config/application.yml.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
RAILS_ENV: 'production'
RABEL_HOST_NAME: 'DOMAIN'
RABEL_SYSTEM_EMAIL: 'hello@DOMAIN'
RABEL_MEMCACHED_SERVER: '127.0.0.1:11011'
RABEL_MEMCACHED_NAMESPACE: 'example'
SESSION_KEY: '_example_session'
SECRET_TOKEN: ''
RABEL_UPYUN_SWITCH: 'off'
RABEL_UPYUN_OP_NAME: 'example'
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# config.logger = SyslogLogger.new

# Use a different cache store in production
config.cache_store = :dalli_store, ENV['RABEL_MEMCACHED_SERVER'], {:namespace => ENV['RABEL_MEMCACHED_NAMESPACE'], :compress => true}
config.cache_store = :dalli_store, Figaro.env['RABEL_MEMCACHED_SERVER'], {:namespace => Figaro.env['RABEL_MEMCACHED_NAMESPACE'], :compress => true}

# Enable serving of images, stylesheets, and JavaScripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
config.mailer_sender = ENV['RABEL_SYSTEM_EMAIL']
config.mailer_sender = Figaro.env['RABEL_SYSTEM_EMAIL']

# Configure the class responsible to send e-mails.
# config.mailer = "Devise::Mailer"
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Rabel::Application.config.secret_token = ENV['SECRET_TOKEN']
Rabel::Application.config.secret_token = Figaro.env['SECRET_TOKEN']
2 changes: 1 addition & 1 deletion config/initializers/session_store.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.

Rabel::Application.config.session_store :cookie_store, key: '_rabel_session'
Rabel::Application.config.session_store :cookie_store, key: Figaro.env['SESSION_KEY']

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
Expand Down

0 comments on commit 6efad4b

Please sign in to comment.