Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4073742
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:04:00+00:00 2026-05-20T17:04:00+00:00

In Rails, when serving static files, you get an asset ID that’s appended to

  • 0

In Rails, when serving static files, you get an asset ID that’s appended to the URL, e.g.,

<script src="/javascripts/application.js?1300371955" ...
<link href="/stylesheets/custom.css?1299690788" ...

This way, the URL of a static file is changed if the file’s timestamp is changed and browsers automatically request the new file.

I saw that by using the helper methods for including static assets — stylesheet_link_tag, javascript_include_tag and image_tag — Rails automatically adds timestamps to all references to those files.

How can I implement something similar for other assets that don’t have such helper methods
e.g., .swf files?

(Does this “strategy” to force the re-download have a name; if so, what is it called?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:04:01+00:00Added an answer on May 20, 2026 at 5:04 pm

    The Rails method that appends the timestamp to assets is called rails_asset_id, and is defined in ActionView::Helpers::AssetTagHelper. Though it is a private method, it can be accessed in a helper to generate one for your custom tags like so:

    def swf_param_tag(path)
      asset_id = rails_asset_id(path)
      "<param name='movie' value='#{path}?#{asset_id}'/>"
    end
    

    It needs you to pass in the path, because it then calls File.mtime(path).to_i.to_s on it to get the last modified time on it.

    There is further explanation about what the asset tag buys you here:
    http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm serving a semi-static site with rails, just to get used to rails conventions.
I have a rails app that I have serving up XML on an infrequent
So I see that there are a few Rails plugins for serving AMF .
I am working on a rails application that uses big javascript libraries (e.g. jquery
I have a nice RESTful controller in my Rails application that uses responds_to to
Currently I have a Rails 2.3 app that is a CMS serving over 100
It is classical scheme of serving Rails application: frontend is Apache (nginx, etc) on
I've been trying to use the code here: http://snafu.diarrhea.ch/blog/article/4-serving-static-content-with-rails but I'm getting errors like:
I'd like for a ruby server script that lives in my rails app root
I'm having problems serving web fonts through Rails 3.1, within a Spree 0.70 application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.