3 class Message < ActiveRecord::Base
4 belongs_to :sender, :class_name => "User", :foreign_key => :from_user_id
5 belongs_to :recipient, :class_name => "User", :foreign_key => :to_user_id
7 validates_presence_of :title, :body, :sent_on, :sender, :recipient
8 validates_length_of :title, :within => 1..255
9 validates_inclusion_of :message_read, :in => [ true, false ]
10 validates_as_utf8 :title
14 md5 << from_user_id.to_s
15 md5 << to_user_id.to_s
16 md5 << sent_on.xmlschema