Skip to content

Instantly share code, notes, and snippets.

@imownbey
Created March 18, 2009 03:02
Show Gist options
  • Save imownbey/80914 to your computer and use it in GitHub Desktop.
Save imownbey/80914 to your computer and use it in GitHub Desktop.
class Message < ActiveRecord::Base
belongs_to :sender, :class_name => "User"
belongs_to :receiver, :class_name => "User"
validates_presence_of :body
before_validation_on_create :set_read
def set_read
self.read = false
end
def not(who)
if self.sender != who
self.sender
else
self.receiver
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment