add access methods for delete

This commit is contained in:
yanxd 2013-12-30 20:16:56 +08:00
parent ebc803a88a
commit 8618ad3ede
1 changed files with 10 additions and 0 deletions

View File

@ -27,6 +27,16 @@ class JournalsForMessage < ActiveRecord::Base
after_destroy :reset_counters!
# default_scope { where('m_parent_id IS NULL') }
def remove_by_user? user
if( self.user == user ||
( self.jour.kind_of?(User) && self.jour== user )
)
true
else
false
end
end
def self.delete_message(message_id)
self.find(message_id).destroy