数据迁移错误

This commit is contained in:
sw 2015-09-29 11:19:53 +08:00
parent 609cba8db3
commit 774b00f2d4
1 changed files with 3 additions and 3 deletions

View File

@ -4,7 +4,7 @@ class AlterActivities < ActiveRecord::Migration
if activity.act_type == 'JournalsForMessage'
if activity.act
unless activity.act.m_parent_id.nil?
parent_act = UserActivity.where("act_id = #{activity.act.parent.id} and act_type='JournalsForMessage' and container_type='Course'").first
parent_act = UserActivity.where("act_id = #{activity.act.m_parent_id} and act_type='JournalsForMessage' and container_type='Course'").first
if parent_act
parent_act.created_at = activity.act.parent.children.maximum("created_on")
parent_act.save
@ -21,7 +21,7 @@ class AlterActivities < ActiveRecord::Migration
if activity.course_act_type == 'JournalsForMessage'
if activity.course_act
unless activity.course_act.m_parent_id.nil?
parent_act = CourseActivity.where("course_act_id = #{activity.course_act.parent.id} and course_act_type='JournalsForMessage'").first
parent_act = CourseActivity.where("course_act_id = #{activity.course_act.m_parent_id} and course_act_type='JournalsForMessage'").first
if parent_act
parent_act.created_at = activity.course_act.parent.children.maximum("created_on")
parent_act.save
@ -34,7 +34,7 @@ class AlterActivities < ActiveRecord::Migration
elsif activity.course_act_type == 'Message'
if activity.course_act
unless activity.course_act.parent_id.nil?
parent_act = CourseActivity.where("course_act_id = #{activity.course_act.parent.id} and course_act_type='Message'").first
parent_act = CourseActivity.where("course_act_id = #{activity.course_act.parent_id} and course_act_type='Message'").first
if parent_act
parent_act.created_at = activity.course_act.parent.children.maximum("created_on")
parent_act.save