|
|
|
@ -34,9 +34,9 @@ class Memo < ActiveRecord::Base
|
|
|
|
|
"forum_id",
|
|
|
|
|
"last_memo_id",
|
|
|
|
|
"lock",
|
|
|
|
|
"sticky",
|
|
|
|
|
"parent_id",
|
|
|
|
|
"replies_count",
|
|
|
|
|
"sticky"
|
|
|
|
|
"replies_count"
|
|
|
|
|
|
|
|
|
|
after_create :add_author_as_watcher, :reset_counters!
|
|
|
|
|
# after_update :update_memos_forum
|
|
|
|
@ -67,10 +67,6 @@ class Memo < ActiveRecord::Base
|
|
|
|
|
end
|
|
|
|
|
forum.reset_counters!
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def sticky=(arg)
|
|
|
|
|
write_attribute :sticky, (arg == true || arg.to_s == 'true' ? true : false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def sticky?
|
|
|
|
|
sticky == 1
|
|
|
|
@ -90,10 +86,14 @@ class Memo < ActiveRecord::Base
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def destroyable_by? user
|
|
|
|
|
user && user.logged? && Forum.find(self.forum_id).creator_id == user.id || user.admin?
|
|
|
|
|
(user && user.logged? && (Forum.find(self.forum_id).creator_id == user.id) ) || user.admin?
|
|
|
|
|
#self.author == user || user.admin?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def deleted_attach_able_by? user
|
|
|
|
|
(user && user.logged? && (self.author == user) ) || user.admin?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def add_author_as_watcher
|
|
|
|
|