Skip to content

Instantly share code, notes, and snippets.

@knowuh
Created March 19, 2013 13:54
Show Gist options
  • Save knowuh/5196292 to your computer and use it in GitHub Desktop.
Save knowuh/5196292 to your computer and use it in GitHub Desktop.
require File.expand_path('../boot', __FILE__)
require 'rails/all'
CONFIG = YAML.load(File.read(File.expand_path('../settings.yml', __FILE__)))
CONFIG.merge! CONFIG.fetch(Rails.env, {})
CONFIG.symbolize_keys!
module RailsPortal
class Application < Rails::Application
config.assets.enabled = true
# Bundler.require(:default, Rails.env) if defined?(Bundler)
# Fixes a Compass bug, per http://stackoverflow.com/questions/6005361/sass-import-error-in-rails-3-app-file-to-import-not-found-or-unreadable-comp?rq=1
Bundler.require(*Rails.groups(:assets => %w(development test))) if defined?(Bundler)
config.autoload_paths += Dir["#{config.root}/lib/**/"] # include lib and all subdirectories
config.autoload_paths += Dir["#{config.root}/app/pdfs/**/"] # include app/reports and all subdirectories
config.filter_parameters << :password << :password_confirmation
# Subvert the cookies_only=true session policy for requests ending in ".config"
config.middleware.insert_before("ActionDispatch::Cookies", "Rack::ConfigSessionCookies")
# ... &etc
config.middleware.insert_before("ActionDispatch::ParamsParser", "Rack::ExpandB64Gzip")
# ... &etc
config.time_zone = 'UTC'
# Set the default location for page caching
config.action_controller.page_cache_directory = ::Rails.root.to_s + '/public'
# ... &etc
if $PROGRAM_NAME =~ /rake/ && ARGV.grep(/^db:migrate/).length > 0
puts "Didn't start observers because you are running: rake db:migrate"
else
begin
config.active_record.observers = :user_observer, :investigation_observer, :"dataservice/bundle_content_observer", :"admin/project_observer", :"dataservice/periodic_bundle_content_observer"
rescue
# interestingly Rails::logger doesn't seem to be working here, so I am using ugly puts for now:
puts "Couldn't start observers #{$!} ... but continuing process anyway"
puts "This might be because you have not setup the appropriate database tables yet... "
puts "see config/initializers/observers.rb for more information."
end
end
end
hostname = CONFIG[:host] || "http://rites.concord.org/"
hostname = hostname.gsub(/^https?:\/\//i,'')
config.action_mailer.default_url_options = {host: CONFIG[:host]}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment