attributes snippets

ActiveRecord's write_attribute is deprecated

Tagged write_attribute, attributes  Languages ruby

ActiveRecord's write_attribute is deprecated, so now you only have one hundred other ways of assigning attributes.

My favorite for dynamic assignment of attributes is:

class Dog
  def crap=(poo)
     self[:trash] = poo # don't try to use self.attributes[:trash] here you fool.
  end

  def crap
     self[:trash] # don't try to use self.attributes[:trash] here you fool.
  end
end