Edit singup's uploaded filename display.

Edit email contents of file upload or edit.
This commit is contained in:
bohung committed 2022-06-18 23:13:29 +08:00
1 parent d1ff3c2c47
commit 4ccc1924bd
8 files changed
+109 -19

No files matched your search

+22
View File
@@ -8,6 +8,7 @@ class SeminarSignupContribute
field :presentation_type , type: String , default: ""
field :sort_number , type: Integer, default: 10000
mount_uploader :file, AssetUploader
field :filename, type: String
field :description
field :preferred_session
field :final_session
@@ -40,4 +41,25 @@ class SeminarSignupContribute
end
end
end
before_save do
self.update_filename
end
def update_filename
if self.title.blank?
self.filename = self.file.file.filename rescue ''
else
if self.file.file
self.filename = self.title.sub(/#{::Regexp.escape(File.extname(self.title))}$/,'') + File.extname(self.file.file.filename)
else
self.filename = self.title
end
end
self.filename
end
def disp_filename
if self.filename.nil?
self.class.where(:id=>self.id).update_all(:filename=>self.update_filename)
end
self.filename
end
end