This commit is contained in:
albert
2013-03-06 20:13:55 -05:00
parent 1582a6135b
commit dba5fd23e1
2 changed files with 23 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ class Dmail < ActiveRecord::Base
validates_presence_of :from_id
validates_format_of :title, :with => /\S/
validates_format_of :body, :with => /\S/
validate :validate_sender_is_not_banned
before_validation :initialize_from_id, :on => :create
belongs_to :owner, :class_name => "User"
belongs_to :to, :class_name => "User"
@@ -153,6 +154,15 @@ class Dmail < ActiveRecord::Base
include FactoryMethods
extend SearchMethods
def validate_sender_is_not_banned
if from.is_banned?
errors[:base] = "Sender is banned and cannot send messages"
return false
else
return true
end
end
def quoted_body
"[quote]#{body}[/quote]"
end