# Image\_path without timestamp

**URL:** <https://www.ruby-forum.com/t/image-path-without-timestamp/144769>\
**Category:** Rails\
**Created:** [August 1, 2008, 9:51pm UTC](https://www.ruby-forum.com/t/image-path-without-timestamp/144769 "2008-08-01T21:51:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![corstar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee59a6/32.png) [@corstar](https://www.ruby-forum.com/u/corstar)\
**Post date:** [August 1, 2008, 9:51pm UTC](https://www.ruby-forum.com/t/image-path-without-timestamp/144769/1 "2008-08-01T21:51:33Z")

</div>

Every time I use an asset tag helper, there is a parameter appended to  
the end of my file name.

e.g.

From what I am reading, this appears to be a timestamp for caching  
purposes. It works in most cases, but I want to use image\_path to embed  
a flash file.

.swf file in public/images/flash

e.g.  
…

....

This outputs the proper path, but appends the timestamp and the flash  
plugin will not display the file. Take the parameter off and it works  
fine.

In production, the app will be deployed in a subdirectory, so the path  
will be different.

Is there a different asset tag helper or approach I should be using?

Thanks,  
Cory

---

<div class="post-metadata">

**Author:** ![corstar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee59a6/32.png) [@corstar](https://www.ruby-forum.com/u/corstar)\
**Post date:** [August 1, 2008, 10:46pm UTC](https://www.ruby-forum.com/t/image-path-without-timestamp/144769/2 "2008-08-01T22:46:11Z")

</div>

> .swf file in public/images/flash  
> fine.
> 
> In production, the app will be deployed in a subdirectory, so the path  
> will be different.
> 
> Is there a different asset tag helper or approach I should be using?

You could roll your own, or look at aliasing rewrite\_asset\_path to not  
append the timestamp if the source matches “.swf”. Or modify  
rails\_asset\_id(). I think you can also disable it completely, but I  
forgot how at the moment.

In vendor/rails/actionpack/lib/action\_view/helpers/asset\_tag\_helper.rb

```
     # Break out the asset path rewrite in case plugins wish to

```

put the asset id  
# someplace other than the query string.  
def rewrite\_asset\_path(source)  
asset\_id = rails\_asset\_id(source)  
if asset\_id.blank?  
source  
else  
source + “?#{asset\_id}”  
end  
end

---

<div class="post-metadata">

**Author:** ![corstar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/ee59a6/32.png) [@corstar](https://www.ruby-forum.com/u/corstar)\
**Post date:** [October 22, 2009, 9:49am UTC](https://www.ruby-forum.com/t/image-path-without-timestamp/144769/3 "2009-10-22T09:49:21Z")

</div>

Hi,

To disable asset\_id completely, simply set the environment variable (for  
instance in environment.rb):

ENV[‘RAILS\_ASSET\_ID’] = “”

cheers

Philip H. wrote:

> > .swf file in public/images/flash  
> > fine.
> > 
> > In production, the app will be deployed in a subdirectory, so the path  
> > will be different.
> > 
> > Is there a different asset tag helper or approach I should be using?
> 
> You could roll your own, or look at aliasing rewrite\_asset\_path to not  
> append the timestamp if the source matches “.swf”. Or modify  
> rails\_asset\_id(). I think you can also disable it completely, but I  
> forgot how at the moment.
> 
> In vendor/rails/actionpack/lib/action\_view/helpers/asset\_tag\_helper.rb
> 
> ```
> # Break out the asset path rewrite in case plugins wish to
> 
> ```
> 
> put the asset id  
> # someplace other than the query string.  
> def rewrite\_asset\_path(source)  
> asset\_id = rails\_asset\_id(source)  
> if asset\_id.blank?  
> source  
> else  
> source + “?#{asset\_id}”  
> end  
> end
