Paperclip how to change basename (filename)?

前端 未结 4 2714
粉色の甜心
粉色の甜心 2021-02-20 15:31

I am trying to change the basename (filename) of photos:

In my model I have:

  attr_accessor :image_url, :basename

  has_attached_file :image,
                  


        
4条回答
  •  长发绾君心
    2021-02-20 16:09

    If you are assigning the file directly you can do this:

    photo.image = the_file
    photo.image.instance_write(:file_name, "the_desired_filename.png")
    photo.save
    

提交回复
热议问题