Rename a file before saving with Paperclip
Par PAB le dimanche 17 mai 2015, 16:30 - Lien permanent
I was recently trying to rename a file before having it saved by Paperclip. As it was not obivous to me, I would like to share the solution with you.
In the model file with the paperclip "definitions", let's add:
and (in my case, the paperclip attachement name is "file")
def rename_file self.file.instance_write :file_name, function_to_change_a_string(file_file_name) end
And it should work. Easy once found :-)