From be218baa52598373329079d2f3c50faafd7b44bc Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 5 Jan 2016 15:59:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=81=E7=A7=BB=EF=BC=9A?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA=E5=8C=BA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message.rb | 3 +-- app/views/my/account.html.erb | 2 +- app/views/users/_project_message.html.erb | 4 +--- ...0105073350_drop_message_for_forge_activities.rb | 14 ++++++++++++++ db/schema.rb | 2 +- 5 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 db/migrate/20160105073350_drop_message_for_forge_activities.rb diff --git a/app/models/message.rb b/app/models/message.rb index 6d108e607..3bb08f481 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -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 diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 65cfd11f3..9cca5da5c 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -44,7 +44,7 @@ - + diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb index 8017081c6..5a9f7e398 100644 --- a/app/views/users/_project_message.html.erb +++ b/app/views/users/_project_message.html.erb @@ -86,9 +86,7 @@
-
回复( - <%=count %> - )
+
回复(<%=count %>)
<%#=format_date(activity.updated_on)%>
<%if count>3 %> diff --git a/db/migrate/20160105073350_drop_message_for_forge_activities.rb b/db/migrate/20160105073350_drop_message_for_forge_activities.rb new file mode 100644 index 000000000..b4fa5e36a --- /dev/null +++ b/db/migrate/20160105073350_drop_message_for_forge_activities.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 3728e8da0..9655824a0 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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