Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Add magic encoding comment to generated files

#4247

This patch allows you to set the way that asset paths are rewritten. My own use case was to accommodate a server setup where not all of the assets have the same mtime even if they're the same file.

If this is not set then it falls back to the default of using ENV['RAILS_ASSET_ID'] or the file mtime.

# config/environments/production.rb
# Normally you'd calculate RELEASE_NUMBER at startup.
RELEASE_NUMBER = 12345
config.action_controller.asset_path_template = proc { |asset_path|
  "/release-#{RELEASE_NUMBER}#{asset_path}"
}

Reported by Craig Webster · March 21st, 2010 @ 08:16 PM

State: resolved
Milestone: none
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: Low

Activity

  1. Craig Webster
    Craig Webster
    • Title changed from Customising asset paths to [PATCH] Customising asset paths

    Fixed a typo in the comments.

    March 21st, 2010 @ 08:22 PM

  2. Stephan Wehner
    Stephan Wehner

    Could you not override the rewrite_asset_path method? There is a comment at line 713 of http://github.com/rails/rails/blob/master/actionpack/lib/action_vie...

        # Break out the asset path rewrite in case plugins wish to put the asset id
        # someplace other than the query string.
    

    Stephan

    March 21st, 2010 @ 08:53 PM

  3. Craig Webster
    Craig Webster

    I could override it but rewrite_asset_path is private and not directly tested so it might go away in the future - possibly without notice. I feel that relying on this largely undocumented method existing in all version of Rails is a bad thing and that providing a tested, documented, public way of customising these paths is a better solution.

    March 21st, 2010 @ 09:08 PM

  4. Stephan Wehner
    Stephan Wehner

    I see. That makes sense.

    To me the comment describes what you're trying to accomplish, so maybe move it and the rewrite_asset_path method into the public section + add tests? Otherwise, I think the comment might as well be dropped.

    Stephan

    March 22nd, 2010 @ 03:35 AM

  5. Craig Webster
    Craig Webster

    Exposing and testing rewrite_asset_path would be acceptable too, although the approach I've taken in the current patch does provide the same sort of API as setting asset_host and I prefer that.

    I'll have a look into doing what you suggest tonight and see where I get. Thanks for your feedback!

    March 22nd, 2010 @ 08:49 AM

  6. Repository
    Repository
    • State changed from new to resolved

    March 29th, 2010 @ 02:46 AM

  7. Ryan Bigg
    Ryan Bigg
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 9th, 2010 @ 10:13 PM

  8. Jeff Kreeftmeijer
  9. Jeff Kreeftmeijer
  10. bingbing