Hi
I want to use the git hash of files as asset id. For that I created an initializer like below.
require 'grit'
module ActionView
module Helpers
module AssetTagHelper
def rewrite_asset_path(source)
asset_id = rails_asset_id(source)
if asset_id.blank?
source
else
"/s/#{asset_id}" + source
end
end
def rails_asset_id(source)
repo = Grit::Repo.new('.')
ENV["RAILS_ASSET_ID"] ||
repo.log('master', "#{RAILS_ROOT}/public/#{source}", :max_count => 1).first.id_abbrev rescue ""
end
end
end
end
This works fine but I want to cache the hash for the files somewhere. I could use an instance variable but I am not sure if those are cleaned per requests. Where can I put that so it persists after the request?