Skip to content

Commit 57f2c1d

Browse files
committed
1320: Remove autosave causing unnecessary N+1 queries
1 parent 2c9e4d4 commit 57f2c1d

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

app/models/concerns/file_concern.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module FileConcern
44
extend ActiveSupport::Concern
55

66
included do
7-
has_many :files, as: :fileable, class_name: 'TaskFile', dependent: :destroy, autosave: true, inverse_of: :fileable
7+
has_many :files, as: :fileable, class_name: 'TaskFile', dependent: :destroy, inverse_of: :fileable
88
accepts_nested_attributes_for :files, allow_destroy: true
99
end
1010

app/models/model_solution.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class ModelSolution < ApplicationRecord
55
include TransferValues
66
include ParentValidation
77

8-
belongs_to :task, autosave: true, inverse_of: :model_solutions
8+
belongs_to :task, inverse_of: :model_solutions
99
belongs_to :parent, class_name: 'ModelSolution', optional: true
1010
has_many :files, as: :fileable, class_name: 'TaskFile', dependent: :destroy
1111
accepts_nested_attributes_for :files, allow_destroy: true

app/models/task_file.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class TaskFile < ApplicationRecord
44
include ParentValidation
55
include TransferValues
66

7-
belongs_to :fileable, polymorphic: true, autosave: true, inverse_of: :files
7+
belongs_to :fileable, polymorphic: true, inverse_of: :files
88
belongs_to :parent, class_name: 'TaskFile', optional: true
99
has_one_attached :attachment
1010
validates :name, presence: true

app/models/test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Test < ApplicationRecord
55
include TransferValues
66
include ParentValidation
77

8-
belongs_to :task, autosave: true, inverse_of: :tests
8+
belongs_to :task, inverse_of: :tests
99
belongs_to :testing_framework, optional: true
1010
belongs_to :parent, class_name: 'Test', optional: true
1111
validates :title, presence: true

0 commit comments

Comments
 (0)