添加迁移:项目讨论区数据重复问题

This commit is contained in:
huang 2016-01-05 15:59:13 +08:00
parent 428eb018a3
commit be218baa52
5 changed files with 18 additions and 7 deletions

View File

@ -199,8 +199,7 @@ class Message < ActiveRecord::Base
def act_as_forge_activity
# 如果project为空那么就是课程相关的消息
if self.board.project_id != -1 && self.parent_id.nil?
self.forge_acts << ForgeActivity.new(:user_id => self.author_id,
:project_id => self.board.project.id)
self.forge_acts << ForgeActivity.new(:user_id => self.author_id, :project_id => self.board.project.id)
end
end

View File

@ -86,9 +86,7 @@
<div class="homepagePostReply">
<div class="topBorder" style="display: <%= count>0 ? 'none': '' %>"></div>
<div class="homepagePostReplyBanner" style="display: <%= count>0 ? '': 'none' %>">
<div class="homepagePostReplyBannerCount" onclick="expand_reply_input('#reply_input_<%= user_activity_id %>');">回复(
<%=count %>
)</div>
<div class="homepagePostReplyBannerCount" onclick="expand_reply_input('#reply_input_<%= user_activity_id %>');">回复(<%=count %>)</div>
<div class="homepagePostReplyBannerTime"><%#=format_date(activity.updated_on)%></div>
<%if count>3 %>
<div class="homepagePostReplyBannerMore"><a id="reply_btn_<%=user_activity_id%>" onclick="expand_reply('#reply_div_<%= user_activity_id %> li','#reply_btn_<%=user_activity_id%>')" data-count="<%= count %>" data-init="0" class=" replyGrey" href="javascript:void(0)" value="show_help" >展开更多</a></div>

View File

@ -0,0 +1,14 @@
class DropMessageForForgeActivities < ActiveRecord::Migration
def up
forge_activities = ForgeActivity.where("forge_act_type =?", "Message")
forge_activities.each do |fa|
# 删除项目动态中,讨论区也会多一条记录问题
if fa.forge_act && !fa.forge_act.parent_id.nil?
fa.delete
end
end
end
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20151231023610) do
ActiveRecord::Schema.define(:version => 20160105073350) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false