I’m trying to instantiate the file from the saved file via paperclip.
The codes to open the file is:
barcodeFile = open(scan.barcode.url,“r”)
…but getting error of file not found as the “url” is extended as
/system/barcodes/1/small/barcode.png?1284296856
with the number strings. I was searching 1) what the numbers strings
are, and 2) how I can get URL without the strings so that I will not
encounter file not found exception when I’m trying to instantiate the
object.
I’ve resolved this issue. I found it on the source code of the library
as below.
# Returns the public URL of the attachment, with a given style.
Note that
# this does not necessarily need to point to a file that your web
server
# can access and can point to an action in your app, if you need
fine
# grained security. This is not recommended if you don’t need the
# security, however, for performance reasons. Set use_timestamp to
false
# if you want to stop the attachment update time appended to the
url
def url(style_name = default_style, use_timestamp = @use_timestamp)
url = original_filename.nil? ? interpolate(@default_url,
style_name) : interpolate(@url, style_name)
use_timestamp && updated_at ? [url,
updated_at].compact.join(url.include?("?") ? “&” : “?”) : url
end
so if you set false, it will turn off adding timestamp at the end.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.