Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
class ActiveRecord::Base def self.unprotected_create!(*args) with_unprotected_attributes { create!(*args) } end def self.unprotected_create(*args) with_unprotected_attributes { create(*args) } end def self.unprotected_new(*args) with_unprotected_attributes { new(*args) } end protected def self.with_unprotected_attributes(&block) previous_attr_protected = read_inheritable_attribute("attr_protected") previous_attr_accessible = read_inheritable_attribute("attr_accessible") write_inheritable_attribute("attr_protected", nil) write_inheritable_attribute("attr_accessible", nil) result = yield write_inheritable_attribute("attr_protected", previous_attr_protected) write_inheritable_attribute("attr_accessible", previous_attr_accessible) result end end
This paste will be private.
From the Design Piracy series on my blog: