From 8618ad3ede60e5fd8a5687f2d3f854ca4a1befbf Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 30 Dec 2013 20:16:56 +0800 Subject: [PATCH] add access methods for delete --- app/models/journals_for_message.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index e83018be..55019788 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -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