Created
November 3, 2011 18:38
-
-
Save ckdake/1337372 to your computer and use it in GitHub Desktop.
Rails 3.1 Assets on S3 with HTTPS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails.env.production? | |
CarrierWave.configure do |config| | |
config.fog_credentials = { | |
provider: 'AWS', | |
aws_access_key_id: ENV['AWS_ACCESS_KEY'], | |
aws_secret_access_key: ENV['AWS_ACCESS_SECRET'], | |
region: 'us-east-1' | |
} | |
config.fog_host = "//#{ENV['MEDIA_BUCKET']}.s3.amazonaws.com" | |
config.fog_directory = ENV['MEDIA_BUCKET'] | |
config.fog_attributes = {'Cache-Control' => 'max-age=315576000'} | |
config.storage = :fog | |
end | |
elsif Rails.env.development? | |
CarrierWave.configure do |config| | |
config.storage = :file | |
config.enable_processing = false | |
end | |
elsif Rails.env.test? or Rails.env.cucumber? | |
CarrierWave.configure do |config| | |
config.storage = :file | |
config.enable_processing = false | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ENV['AWS_ACCESS_KEY'] = 'XXX' | |
ENV['AWS_ACCESS_SECRET'] = 'XXXXXX' | |
ENV['AWS_BUCKET'] = 'bucket-example-com' | |
desc "deploys to heroku after uploading assets to S3" | |
task deploy: [:environment, 'assets:precompile'] do | |
puts `git push heroku` | |
puts `rake assets:clean` | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'fog' # Storage on S3 for carrierwave | |
gem 'rmagick' # Resizes images and makes thumbnails | |
gem 'carrierwave' # Image attachments, newer version doesn't work with local files preview hack | |
gem 'asset_sync' # Syncs assets to S3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config.action_controller.asset_host = "//#{ENV['AWS_BUCKET']}.s3.amazonaws.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment