Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Beginnings of config framework

Ability to keep configuration in a git ignored config file or pull
from environment variables.
  • Loading branch information...
commit 70080cb3605108af938b528df3b2a2b91cbc8ffa 1 parent 56f61b1
@malclocke malclocke authored
View
1  .gitignore
@@ -1,4 +1,5 @@
config/database.yml
+config/fulcrum.rb
.bundle
db/*.sqlite3
log/*.log
View
1  Gemfile
@@ -16,6 +16,7 @@ gem 'jquery-rails'
gem 'devise'
gem 'transitions', '0.0.9', :require => ["transitions", "active_record/transitions"]
gem 'i18n-js'
+gem 'configuration'
gem 'fastercsv', '1.5.3', :platforms => :ruby_18
# (using standard csv lib if ruby version is 1.9)
View
2  Gemfile.lock
@@ -48,6 +48,7 @@ GEM
sass (~> 3.1)
compass-rails (1.0.0.rc.3)
compass (~> 0.12.rc.0)
+ configuration (1.3.2)
database_cleaner (0.7.1)
devise (2.0.4)
bcrypt-ruby (~> 3.0)
@@ -169,6 +170,7 @@ PLATFORMS
DEPENDENCIES
capybara
compass-rails
+ configuration
database_cleaner
devise
ejs
View
21 README.md
@@ -79,13 +79,13 @@ to the previous section for instructions. Then:
# Create your app. Replace APPNAME with whatever you want to name it.
$ heroku create APPNAME --stack cedar
- # Set APP_NAME heroku config so outbound emails have a proper host
- # Replace MYAPPNAME below with the value from `heroku create`
- $ heroku config:add APP_NAME=MYAPPNAME
+ # Set APP_HOST heroku config so outbound emails have a proper host
+ # Replace APPNAME below with the value from `heroku create`
+ $ heroku config:set APP_HOST=APPNAME.herokuapp.com
# Define where the user emails will be coming from
# (This email address does not need to exist)
- $ heroku config:add MAILER_SENDER=noreply@example.org
+ $ heroku config:set MAILER_SENDER=noreply@example.org
# Allow emails to be sent
$ heroku addons:add sendgrid:starter
@@ -99,6 +99,19 @@ to the previous section for instructions. Then:
Once that's done, you will be able to view your site at
`http://APPNAME.herokuapp.com`.
+Deploying to other platforms
+----------------------------
+
+Fulcrum can be deployed to any platform that can host Rails. Setting this
+up is beyond the scope of this document, but for the most part Fulcrum does
+not have any special operational requirements and can be deployed as a normal
+Rails application.
+
+You will need to set up some custom configuration, to do this copy the file
+`config/fulcrum.example.rb` to `config/fulcrum.rb` and edit to your
+requirements, or ensure the relevant environment variables are set for the
+application as described in the file above.
+
Translating
-----------
View
6 config/application.rb
@@ -49,5 +49,11 @@ class Application < Rails::Application
# Do not initialize the whole Rails stack when precompiling assets
config.assets.initialize_on_precompile = false
+
+ load Rails.root.join('config','fulcrum_defaults.rb')
+ if File.exist?(Rails.root.join('config', 'fulcrum.rb'))
+ load Rails.root.join('config','fulcrum.rb')
+ end
+ config.fulcrum = ::Configuration.for 'fulcrum'
end
end
View
2  config/environments/development.rb
@@ -16,7 +16,7 @@
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_deliveries = false
- config.action_mailer.default_url_options = { :host => '127.0.0.1:3000' }
+ config.action_mailer.default_url_options = { :host => config.fulcrum.app_host }
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
View
2  config/environments/production.rb
@@ -47,7 +47,7 @@
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
- config.action_mailer.default_url_options = { :host => "#{ENV['APP_NAME']}.herokuapp.com" }
+ config.action_mailer.default_url_options = { :host => config.fulcrum.app_host }
# Enable threaded mode
# config.threadsafe!
View
8 config/fulcrum.example.rb
@@ -0,0 +1,8 @@
+Configuration.for('fulcrum') do
+ # Set this to the domain name of your installation. Env var APP_HOST
+ #app_host 'example.com'
+
+ # The email address that notification emails will be sent from. Env var
+ # MAILER_SENDER
+ #mailer_sender 'noreply@example.com'
+end
View
7 config/fulcrum_defaults.rb
@@ -0,0 +1,7 @@
+Configuration.for('fulcrum') do
+ # On Heroku, ensure you `heroku config:add APP_HOST=appname.herokuapp.com`
+ app_host ENV['APP_HOST'] || '127.0.0.1:3000'
+
+ # The address which system emails will originate from.
+ mailer_sender ENV['MAILER_SENDER'] || 'noreply@example.com'
+end
View
2  config/initializers/devise.rb
@@ -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 = "please-change-me-at-config-initializers-devise@example.com"
+ config.mailer_sender = Rails.application.config.fulcrum.mailer_sender
# Configure the class responsible to send e-mails.
# config.mailer = "Devise::Mailer"
Please sign in to comment.
Something went wrong with that request. Please try again.