I've followed this tutorial on customizing filenames in attachment_fu and it all works correctly except for one thing.
Despite correctly renaming the file itself and saving it in the correct location, the name of the file in the 'filename' field in the database doesn't get updated...it stays the same as the name of the file itself instead of getting renamed.
Any idea how to get the filename field to update?
For reference, here's my model:
Code:has_attachment :content_type => :image, :storage => :file_system, :max_size => 500.kilobytes, :resize_to => '50x40!', :path_prefix => 'public/files/tutorials' validates_as_attachment def full_filename(thumbnail = nil) file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix] case self.thumbnail when "thumb" File.join(RAILS_ROOT, file_system_path, 'thumb', thumbnail_name_for(thumbnail, self.parent_id)) else File.join(RAILS_ROOT, file_system_path, 'fullsize', thumbnail_name_for(thumbnail, self.id)) end end def thumbnail_name_for(thumbnail = nil, asset = nil) extension = filename.scan(/\.\w+$/) return "#{asset}#{extension}" end




Bookmarks