Skip to content

Instantly share code, notes, and snippets.

@tadman
Created February 11, 2010 05:18
Show Gist options
  • Save tadman/301250 to your computer and use it in GitHub Desktop.
Save tadman/301250 to your computer and use it in GitHub Desktop.
module ActionView
module Helpers
def write_asset_file_contents(joined_asset_path, asset_paths)
FileUtils.mkdir_p(File.dirname(joined_asset_path))
File.atomic_write(joined_asset_path, File.join(Rails.root, 'tmp')) { |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
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment