Skip to content

Instantly share code, notes, and snippets.

@Ferdi
Forked from simplyb/previously_dirty.rb
Created September 12, 2012 14:45
Show Gist options
  • Select an option

  • Save Ferdi/3707112 to your computer and use it in GitHub Desktop.

Select an option

Save Ferdi/3707112 to your computer and use it in GitHub Desktop.
module PreviouslyDirty
extend ActiveSupport::Concern
included do
attribute_method_suffix '_previously_changed?'
end
private
# Handle <tt>*_previously_changed?</tt> for +method_missing+.
def attribute_previously_changed?(attr)
previous_changes.include?(attr)
end
end
class ActiveRecord::Base
self.send(:include, PreviouslyDirty)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment