Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Add asset_sync gem
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdgs88 authored and pablorc committed Oct 18, 2018
1 parent c57db44 commit 12c33a4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions recipes/carrier_wave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ class CarrierWave < Base

def gems
@template.gem 'carrierwave'
@template.gem 'asset_sync'
@template.gem 'fog-aws'
end

def cook
add_initializer
add_application_config
add_production_env_config
end

private

def add_initializer
@template.initializer 'carrierwave.rb', <<~CODE
require 'carrierwave/storage/fog'
CarrierWave.configure do |config|
Expand All @@ -29,7 +38,9 @@ def cook
}
end
CODE
end

def add_application_config
@template.inside 'config' do
@template.append_file 'application.yml.example', "\nAWS_ACCESS_KEY: ''"
@template.append_file 'application.yml', "\nAWS_ACCESS_KEY: ''"
Expand All @@ -40,5 +51,10 @@ def cook
end
end

def add_production_env_config
@template.gsub_file 'config/environments/production.rb',
'# config.action_controller.asset_host = \'http://assets.example.com\'',
'config.action_controller.asset_host = "//#{ENV[\'FOG_DIRECTORY\']}.s3.amazonaws.com"'
end
end
end

0 comments on commit 12c33a4

Please sign in to comment.