ruby-on-rails – Paperclip如何更改basename(filename)?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – Paperclip如何更改basename(filename)?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试更改照片的basename(filename):

在我的模型中,我有:

attr_accessor :image_url,:basename

  has_attached_file :image,:styles => { :original => ["300x250>",:png],:small => ["165x138>",:png] },:url  => "/images/lille/:style/:id/:basename.:extension",:path => ":rails_root/public/images/lille/:style/:id/:basename.:extension"
before_save :basename
private

  def basename
  self.basename = "HALLLO"
  end

文件名完全没有改变.

解决方法

猜你在找的Ruby相关文章