Paperclip - How do I create a timestamp added to a file name?

I use Paperclip to store images using S3. I understand that Paperclip will add a line (timestamp) to the end of the image for caching purposes. Do you know which method they use to create the string? I need to rebuild it with .js, here's why:

I get content using jQuery $ .getJSON, parsing the response data, creating an array and adding it to the DOM. Everything works fine with this, but I need to add a line at the end of the file name.

Here is an example:

<img src="http://s3.amazonaws.com/some_bucket/some_image.jpg?1293603533" />

Although the URL is an example, the line appended to the file name is current. Here are the other data in this image.

image_file_size: 159713 
image_height: 415   
image_width: 900    
image_updated_at: 2010-12-29 06:18:53

, , ":" "-" image_updated_at, . ? - ? !

+3
2

Rails, asset_id :

File.mtime(path).to_i.to_s 

, Time integer. ruby ​​docs , .

js , ruby ​​ to_i. , .

+3

image_updated_at.to_i - , , .

0

Source: https://habr.com/ru/post/1782559/


All Articles