parent
16e018a444
commit
48ddee478e
|
@ -116,9 +116,24 @@ class MemosController < ApplicationController
|
|||
REPLIES_PER_PAGE = 20 unless const_defined?(:REPLIES_PER_PAGE)
|
||||
def show
|
||||
# 更新贴吧帖子留言对应的memo_messages的viewed字段
|
||||
query_memo_messages = @memo.memo_messages
|
||||
pre_count = REPLIES_PER_PAGE
|
||||
unless @memo.children.blank?
|
||||
@memo.children.each do |child|
|
||||
child.memo_messages.each do |memo_message|
|
||||
if User.current.id == memo_message.user_id
|
||||
memo_message.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
query_memo_messages = @memo.memo_messages
|
||||
query_memo_messages.each do |query_memo_message|
|
||||
if User.current.id == query_memo_message.user_id
|
||||
query_memo_message.update_attributes(:viewed => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
pre_count = REPLIES_PER_PAGE
|
||||
@memo = @memo.root # 取出楼主,防止输入帖子id让回复作为主贴显示
|
||||
@memo.update_column(:viewed_count, (@memo.viewed_count.to_i + 1))
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ class AboutMemoMessage < ActiveRecord::Migration
|
|||
end
|
||||
end
|
||||
receivers.each do |r|
|
||||
memo.memo_messages << MemoMessage.new(:user_id => r.id, :forum_id => memo.forum_id, :memo_id => memo.id, :memo_type => "Memo", :viewed => false)
|
||||
memo.memo_messages << MemoMessage.new(:user_id => r.id, :forum_id => memo.forum_id, :memo_id => memo.id, :memo_type => "Memo", :viewed => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -23,7 +23,7 @@ class AboutUserFeedbackMessage < ActiveRecord::Migration
|
|||
unless receivers.blank?
|
||||
receivers.each do |r|
|
||||
puts jour_for_message.id
|
||||
jour_for_message.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => jour_for_message.id, :journals_for_message_type => "Principal", :viewed => false)
|
||||
jour_for_message.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => jour_for_message.id, :journals_for_message_type => "Principal", :viewed => true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue