I am trying to change the basename (filename) of photos:
In my model I have:
attr_accessor :image_url, :basename
has_attached_file :image,
I wanted to avoid having to add a before_create
callback to every model with an attachment. I had a look at the source and at the time of this writing it looked sth like:
module Paperclip
class Attachment
...
def assign_file_information
instance_write(:file_name, cleanup_filename(@file.original_filename))
instance_write(:content_type, @file.content_type.to_s.strip)
instance_write(:file_size, @file.size)
end
So you could just patch cleanup_filename
.
module Paperclip
class Attachment
def cleanup_filename(filename)
"HALLLO"
end
end
end