This is my model
class Technology < ActiveRecord::Base attr_accessible :name #etc .... has_attached_file :logo, :path => ":rails_root/public/technologies/logos/:normalized_input_file_name" Paperclip.interpolates :normalized_input_file_name do |attachment, style| attachment.instance.normalized_input_file_name end def normalized_input_file_name name = "#{self.name}".downcase "#{self.tuid}_"+name.gsub(/[^a-zA-Z0-9]{2,}/,' ').strip.gsub(/\W/,'_').gsub(/\A_/,'').gsub(/_\z/,'')+"_150x"+".png" end end
When I create any technology, I upload the logo and image stored in the public directory with a new name for it, since I want to use the "normalized_input_file_name" method. For example, the technology name is HTML5, and the file name becomes id_html5_150x.png But when I need to update the name, the image path also changed. for example, the HTML 5 file name becomes id_html_5_150x.png Here the actual image file name is not updated But the path is updated. Therefore, I can not find the image.
source share