You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
class ModifyViewedCountForSubjects < ActiveRecord::Migration[5.2]
|
|
def change
|
|
|
|
subjects = Subject.where(status: 2).includes(:shixuns)
|
|
subjects.find_each do |subject|
|
|
subject.update_attribute(:visits, subject.visits + subject.shixuns.pluck(:myshixuns_count).sum)
|
|
end
|
|
|
|
end
|
|
end
|