自定义attachment_fu插件上传的文件名
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
class QuestionAttachment < ActiveRecord::Base belongs_to :question has_attachment :content_type => :image, :storage => :file_system, :path_prefix => 'public/question_files' def sanitize_filename(filename) return unless filename returning filename.strip do |name| name.gsub! /^[^\.]+/, 'customed filename' end end end |
直对单个后缀的文件有用,对xxx.tar.gz型文件名需要修改
name.gsub! /^[^\.]+/, 'customed filename'
Posted by holin At August 14, 2008 02:15
请登录以发表评论。