Skip to content

Instantly share code, notes, and snippets.

@jmhodges
Created April 20, 2009 21:34
Show Gist options
  • Save jmhodges/98777 to your computer and use it in GitHub Desktop.
Save jmhodges/98777 to your computer and use it in GitHub Desktop.
module ClassMethods
def blamed
- belongs_to :creator, :class_name => 'Person'
- belongs_to :updater, :class_name => 'Person'
+ class_eval do
+ attr_accessor :current_updater
+
+ belongs_to :creator, :class_name => 'Person'
+ belongs_to :updater, :class_name => 'Person'
+ validates_presence_of :creator
+ validates_presence_of(:current_updater,
+ :unless => proc{|m| m.new_record?}
+ )
+
+ def current_updater=(up)
+ @current_updater = up
+ self.updater = up
+ end
+
+ end
end
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment