diff --git a/lib/tasks/public_course.rake b/lib/tasks/public_course.rake index 67d5603ab..ff50a4e28 100644 --- a/lib/tasks/public_course.rake +++ b/lib/tasks/public_course.rake @@ -68,12 +68,15 @@ namespace :public_course do case type.to_i when 1 # 讨论区 - created_on = random_time start_time, end_time - puts created_on messages = Message.where(board_id: course.boards) messages.each do |message| + created_on = random_time start_time, end_time + puts created_on message.update_columns(created_on: created_on, updated_on: created_on) - MessageDetail.where(message_id: message.id).update_all(created_at: created_on, updated_at: created_on) + MessageDetail.where(message_id: message.id).each do |detail| + rand_created_on = random_time start_time, end_time + detail.update_columns(created_at: rand_created_on, updated_at: rand_created_on) + end end when 2 # 作业