Remove Question Mark from Files Created with a Clipclip in Ruby on Rails 3.2.6

I use Paperclip-FFMEG to upload video files to my development environment (and, ultimately, to the local server when my project goes into production).

When videos are uploaded, the default file name is as follows:

/system/modelnames/paperclipnames/.../mynewfile.mp4?xxxxxxxxxx

I believe that the number 10 digits after the question mark is a timestamp.

However, the player that I will use to play the video does not want to have anything after attaching the file, so I would like to remove the question mark and timestamp after it before transferring the URL to the player.

I tried using the following Ruby function (I think):

temp_variable = model.paperclipattribute.url(:blah).strip('?')[0]

However, Rails raises an error:

wrong number of arguments(1 for 0)

, ? ? , .

!

+5
4

, use_timestamp has_attached_file . , , " ":

has_attached_file :avatar,
  :styles => { :medium => "300x300>", :thumb => "100x100>" },
  :default_url => "/images/:style/missing.png",
  :use_timestamp => false
+16

, , ( , ), , ( ) , false URL() :

model.paperclipattribute.url(:whateverstyle, false)

. , , split, , , , , - "Is_this_a_question _? _ Yes_it_is.mp4? Xxxxxx", (.. " _", .

, .

+6

Disable them globally by default, just put this in the config / initializers / paperclip.rb file.

Paperclip::Attachment.default_options[:use_timestamp] = false

+5
source

Instead, you want to use split. strip takes no arguments, it just removes leading and trailing spaces

+2
source

All Articles