How can I only allow updating of nil attributes for a Rails ActiveRecord object? -


i have activerecord object multiple attributes allowed nil on creation , can later updated user through form. however, once attribute changed nil non-nil, attribute may not updated again. how should go setting behavior?

create_table :funky |t|   t.integer :fireflies end  class funky < activerecord::base   def fireflies=(ff)     raise "uh uh.. set" unless self.fireflies.blank?      write_attribute(:fireflies, ff)   end end 

editing post user requested many fields edited

[:one, :two, :three].each |s|   define_method "#{s}=" |v|             raise "uh uh.. set" unless self.send(s).blank?      write_attribute(s, v)   end end