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
This commit is contained in:
Steven Hancock 2012-04-04 04:14:56 -07:00
parent f86aab3fe2
commit 39b0c2de11
2 changed files with 12 additions and 2 deletions

View file

@ -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'

View file

@ -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