diff --git a/app/models/exercise.rb b/app/models/exercise.rb index 80725981..53a3ee26 100644 --- a/app/models/exercise.rb +++ b/app/models/exercise.rb @@ -155,8 +155,6 @@ def before_publication end end - protected - def has_questions return unless questions.first.nil? errors.add(:questions, "can't be blank") diff --git a/db/migrate/20220302162344_create_slug_tags.rb b/db/migrate/20220302162344_create_slug_tags.rb index 48cc1355..3732575a 100644 --- a/db/migrate/20220302162344_create_slug_tags.rb +++ b/db/migrate/20220302162344_create_slug_tags.rb @@ -4,8 +4,8 @@ class CreateSlugTags < ActiveRecord::Migration[6.1] def up Exercise.preload(:publication).in_batches(of: 100, load: true) do |exercises| Exercise.transaction do - exercises.each(&:save) # creates the slug tags but does not set updated_at - exercises.update_all(updated_at: Time.current) # invalidates the exercise cache + exercises.each(&:set_slug_tags) + exercises.update_all updated_at: Time.current end end end