title: Rails: saving a string on an object -- syntax problem?
body: <p>I am trying to write a simple function to clean a filename string and update the object.  When I save a test string it works, but when I try to save the string variable I've created, nothing happens.  But when I return the string, the output seems to be correct!  What am I missing?</p>
  
  <pre><code> def clean_filename    
     clean_name = filename
     clean_name.gsub! /^.*(\\|\/)/, ''
     clean_name.gsub! /[^A-Za-z0-9\.\-]/, '_'
     clean_name.gsub!(/\_+/, ' ')
     #update_attribute(:filename, "test") #&lt;-- correctly sets filename to test
     #update_attribute(:filename, clean_name) #&lt;-- no effect????? WTF
     #return clean_name &lt;-- seems to returns the correct string
   end
  </code></pre>
  
  <p>Thank you very much.</p>