Skip to content

Instantly share code, notes, and snippets.

@miloops
Created September 15, 2009 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miloops/187275 to your computer and use it in GitHub Desktop.
Save miloops/187275 to your computer and use it in GitHub Desktop.
module ActionView
module Helpers
module AssetTagHelper
private
# def write_asset_file_contents(joined_asset_path, asset_paths)
# FileUtils.mkdir_p(File.dirname(joined_asset_path))
# File.open(joined_asset_path, "w+") { |cache| cache.write(join_asset_file_contents(asset_paths)) }
# # Set mtime to the latest of the combined files to allow for
# # consistent ETag without a shared filesystem.
# mt = asset_paths.map { |p| File.mtime(asset_file_path(p)) }.max
# File.utime(mt, mt, joined_asset_path)
# end
def write_asset_file_contents_with_s3_support(joined_asset_path, asset_paths)
file = write_asset_file_contents_without_s3_support(joined_asset_path, asset_paths)
asset = joined_asset_path.split("/")[-2..-1].join("/")
system("ruby #{RAILS_ROOT}/script/s3sync/s3cmd.rb -v put eventioz_#{Rails.env}:#{asset} #{joined_asset_path} x-amz-acl:public-read")
file
end
alias_method_chain :write_asset_file_contents, :s3_support
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment