From 39b0c2de113d8e8315e5992ae5205740cf24f45c Mon Sep 17 00:00:00 2001 From: Steven Hancock Date: Wed, 4 Apr 2012 04:14:56 -0700 Subject: [PATCH] Only load Asset Sync when S3 is configured I consider this a hack, it needs review so I won't push it straight to the main repo. I tried putting the same code in an initializer but that appears to be too late to properly initialize the asset_sync engine. See diaspora/diaspora#3102 --- Gemfile | 4 +++- config/application.rb | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 992166e92..1a82058dd 100644 --- a/Gemfile +++ b/Gemfile @@ -119,7 +119,9 @@ group :assets do gem 'handlebars_assets' gem 'uglifier' - gem "asset_sync" + + # asset_sync is required as needed by application.rb + gem "asset_sync", :require => nil end gem 'jquery-rails' diff --git a/config/application.rb b/config/application.rb index 117e03c98..1e1a62d0e 100644 --- a/config/application.rb +++ b/config/application.rb @@ -14,9 +14,12 @@ end require 'rails/all' +# Sanitize groups to make matching :assets easier +RAILS_GROUPS = Rails.groups(:assets => %w(development test)).map { |group| group.to_sym } + if defined?(Bundler) # If you precompile assets before deploying to production, use this line - Bundler.require(*Rails.groups(:assets => %w(development test))) + Bundler.require(*RAILS_GROUPS) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end @@ -90,3 +93,8 @@ module Diaspora end end + +# Only load asset_sync if S3 is configured +if RAILS_GROUPS.include?(:assets) && ENV['AWS_ACCESS_KEY_ID'] + require 'asset_sync' +end \ No newline at end of file