sikachu / sprockets-redirect

A Rack middleware for Rails >= 3.1.0 with asset pipeline and asset digest enabled. This middleware is used to redirect any request to static asset without a digest to the version with digest in its filename by reading the assets manifest file generated after you run `rake assets:precompile`
http://rubygems.org/gems/sprockets-redirect
MIT License
72 stars 26 forks source link

Does not redirect to asset_host of asset_host is a proc #9

Closed ryanong closed 8 years ago

ryanong commented 9 years ago

Hey Prem!

our asset_host uses a proc

config.action_controller.asset_host = proc |source, request|
  unless source.start_with?("/dynamic_asset")
    "sha.cloudfront.net"
  end
end

I was thinking of submitting a pull request that uses #asset_path from ActionView::Helpers::AssetUrlHelper instead of trying to compute it ourselves. Thoughts?

sikachu commented 9 years ago

I think adding proc support would be better though. I think that would make it less-coupled to Rails.

Then, if we want to DRY it up, we could just read the config.action_controller.asset_host and set it in Railtie. That way you don't have to copy & paste the same proc into two places.

Am I understanding this correctly? Please let me know.

ryanong commented 9 years ago

Partially? I have enough direction to make a PR. Then it will be clear