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_associated :sender, :recipient
11 validates_as_utf8 :title