Skip to content

Commit 5583de0

Browse files
committed
Autocorrect Rubocop errors
1 parent 01ddd0f commit 5583de0

14 files changed

Lines changed: 41 additions & 41 deletions

app/controllers/admin/projects_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def scoped_resource
1111
def destroy_image
1212
image = requested_resource.images.find(params[:image_id])
1313
image.purge
14-
redirect_back(fallback_location: requested_resource)
14+
redirect_back_or_to(requested_resource)
1515
end
1616

1717
private

app/controllers/api/class_members_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def index
1717
@class_members = result[:class_members]
1818
render :index, formats: [:json], status: :ok
1919
else
20-
render json: { error: result[:error] }, status: :unprocessable_entity
20+
render json: { error: result[:error] }, status: :unprocessable_content
2121
end
2222
end
2323

@@ -39,10 +39,10 @@ def create
3939
@class_member = result[:class_members].first
4040
render :show, formats: [:json], status: :created
4141
else
42-
render json: result.slice(:error, :errors), status: :unprocessable_entity
42+
render json: result.slice(:error, :errors), status: :unprocessable_content
4343
end
4444
rescue ArgumentError => e
45-
render json: { error: e.message }, status: :unprocessable_entity
45+
render json: { error: e.message }, status: :unprocessable_content
4646
end
4747

4848
def create_batch
@@ -53,7 +53,7 @@ def create_batch
5353
result = ClassMember::Create.call(school_class: @school_class, students:, teachers:)
5454

5555
if result.failure? && result[:error].include?('No valid school members provided')
56-
render json: result, status: :unprocessable_entity
56+
render json: result, status: :unprocessable_content
5757
else
5858
successful = result[:class_members].map { |m| { success: true, user_id: m.user_id } }
5959
errors = result[:errors].map { |user_id, error| { success: false, user_id:, error: } }
@@ -67,7 +67,7 @@ def destroy
6767
if result.success?
6868
head :no_content
6969
else
70-
render json: { error: result[:error] }, status: :unprocessable_entity
70+
render json: { error: result[:error] }, status: :unprocessable_content
7171
end
7272
end
7373

app/controllers/api/feedback_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def create
2626
@feedback = result[:feedback]
2727
render :show, formats: [:json], status: :created
2828
else
29-
render json: { error: result[:error] }, status: :unprocessable_entity
29+
render json: { error: result[:error] }, status: :unprocessable_content
3030
end
3131
end
3232

@@ -38,7 +38,7 @@ def set_read
3838
@feedback = result[:feedback]
3939
render :show, formats: [:json], status: :ok
4040
else
41-
render json: { error: result[:error] }, status: :unprocessable_entity
41+
render json: { error: result[:error] }, status: :unprocessable_content
4242
end
4343
end
4444

@@ -48,7 +48,7 @@ def destroy
4848
if result.success?
4949
head :no_content
5050
else
51-
render json: { error: result[:error] }, status: :unprocessable_entity
51+
render json: { error: result[:error] }, status: :unprocessable_content
5252
end
5353
end
5454

app/controllers/api/lessons_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def create
3333
@lesson_with_user = result[:lesson].with_user
3434
render :show, formats: [:json], status: :created
3535
else
36-
render json: { error: result[:error] }, status: :unprocessable_entity
36+
render json: { error: result[:error] }, status: :unprocessable_content
3737
end
3838
end
3939

@@ -44,7 +44,7 @@ def create_copy
4444
@lesson_with_user = result[:lesson].with_user
4545
render :show, formats: [:json], status: :created
4646
else
47-
render json: { error: result[:error] }, status: :unprocessable_entity
47+
render json: { error: result[:error] }, status: :unprocessable_content
4848
end
4949
end
5050

@@ -57,7 +57,7 @@ def update
5757
@lesson_with_user = result[:lesson].with_user
5858
render :show, formats: [:json], status: :ok
5959
else
60-
render json: { error: result[:error] }, status: :unprocessable_entity
60+
render json: { error: result[:error] }, status: :unprocessable_content
6161
end
6262
end
6363

app/controllers/api/projects_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def create
3333
@project = result[:project]
3434
render :show, formats: [:json], status: :created
3535
else
36-
render json: { error: result[:error] }, status: :unprocessable_entity
36+
render json: { error: result[:error] }, status: :unprocessable_content
3737
end
3838
end
3939

@@ -43,7 +43,7 @@ def update
4343
if result.success?
4444
render :show, formats: [:json]
4545
else
46-
render json: { error: result[:error] }, status: :unprocessable_entity
46+
render json: { error: result[:error] }, status: :unprocessable_content
4747
end
4848
end
4949

app/controllers/api/school_classes_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def create
3030
@school_class_with_teachers = result[:school_class].with_teachers
3131
render :show, formats: [:json], status: :created
3232
else
33-
render json: { error: result[:error] }, status: :unprocessable_entity
33+
render json: { error: result[:error] }, status: :unprocessable_content
3434
end
3535
end
3636

@@ -55,7 +55,7 @@ def import
5555

5656
render :import, formats: [:json], status: :created
5757
else
58-
render json: { error: school_class_result[:error] }, status: :unprocessable_entity
58+
render json: { error: school_class_result[:error] }, status: :unprocessable_content
5959
end
6060
end
6161

@@ -67,7 +67,7 @@ def update
6767
@school_class_with_teachers = result[:school_class].with_teachers
6868
render :show, formats: [:json], status: :ok
6969
else
70-
render json: { error: result[:error] }, status: :unprocessable_entity
70+
render json: { error: result[:error] }, status: :unprocessable_content
7171
end
7272
end
7373

@@ -77,7 +77,7 @@ def destroy
7777
if result.success?
7878
head :no_content
7979
else
80-
render json: { error: result[:error] }, status: :unprocessable_entity
80+
render json: { error: result[:error] }, status: :unprocessable_content
8181
end
8282
end
8383

app/controllers/api/school_members_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def index
1515
@school_members = result[:school_members]
1616
render :index, formats: [:json], status: :ok
1717
else
18-
render json: { error: result[:error] }, status: :unprocessable_entity
18+
render json: { error: result[:error] }, status: :unprocessable_content
1919
end
2020
end
2121

app/controllers/api/school_owners_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def index
1313
@school_owners = result[:school_owners]
1414
render :index, formats: [:json], status: :ok
1515
else
16-
render json: { error: result[:error] }, status: :unprocessable_entity
16+
render json: { error: result[:error] }, status: :unprocessable_content
1717
end
1818
end
1919
end

app/controllers/api/school_projects_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def unsubmit
1717
@school_project = result[:school_project]
1818
render :show_status, formats: [:json], status: :ok
1919
else
20-
render json: { error: result[:error] }, status: :unprocessable_entity
20+
render json: { error: result[:error] }, status: :unprocessable_content
2121
end
2222
end
2323

@@ -28,7 +28,7 @@ def submit
2828
@school_project = result[:school_project]
2929
render :show_status, formats: [:json], status: :ok
3030
else
31-
render json: { error: result[:error] }, status: :unprocessable_entity
31+
render json: { error: result[:error] }, status: :unprocessable_content
3232
end
3333
end
3434

@@ -39,7 +39,7 @@ def return
3939
@school_project = result[:school_project]
4040
render :show_status, formats: [:json], status: :ok
4141
else
42-
render json: { error: result[:error] }, status: :unprocessable_entity
42+
render json: { error: result[:error] }, status: :unprocessable_content
4343
end
4444
end
4545

@@ -50,7 +50,7 @@ def complete
5050
@school_project = result[:school_project]
5151
render :show_status, formats: [:json], status: :ok
5252
else
53-
render json: { error: result[:error] }, status: :unprocessable_entity
53+
render json: { error: result[:error] }, status: :unprocessable_content
5454
end
5555
end
5656

@@ -67,7 +67,7 @@ def set_finished
6767
@school_project = result[:school_project]
6868
render :finished, formats: [:json], status: :ok
6969
else
70-
render json: { error: result[:error] }, status: :unprocessable_entity
70+
render json: { error: result[:error] }, status: :unprocessable_content
7171
end
7272
end
7373

app/controllers/api/school_students_controller.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def index
1919
@school_students = result[:school_students]
2020
render :index, formats: [:json], status: :ok
2121
else
22-
render json: { error: result[:error] }, status: :unprocessable_entity
22+
render json: { error: result[:error] }, status: :unprocessable_content
2323
end
2424
end
2525

@@ -31,7 +31,7 @@ def create
3131
if result.success?
3232
head :no_content
3333
else
34-
render json: { error: result[:error] }, status: :unprocessable_entity
34+
render json: { error: result[:error] }, status: :unprocessable_content
3535
end
3636
end
3737

@@ -41,7 +41,7 @@ def create_batch
4141
error: StandardError,
4242
error_type: :unprocessable_entity
4343
},
44-
status: :unprocessable_entity
44+
status: :unprocessable_content
4545
return
4646
end
4747

@@ -57,7 +57,7 @@ def create_batch
5757
render json: {
5858
error: validation_result[:error],
5959
error_type: validation_result[:error_type]
60-
}, status: :unprocessable_entity
60+
}, status: :unprocessable_content
6161
return
6262
end
6363

@@ -66,7 +66,7 @@ def create_batch
6666
enqueue_batches(students)
6767
rescue StandardError => e
6868
Rails.logger.error "Failed to enqueue GoodJob Batch: #{e}"
69-
render json: { error: e, error_type: :batch_error }, status: :unprocessable_entity
69+
render json: { error: e, error_type: :batch_error }, status: :unprocessable_content
7070
return
7171
end
7272

@@ -105,7 +105,7 @@ def update
105105
if result.success?
106106
head :no_content
107107
else
108-
render json: { error: result[:error] }, status: :unprocessable_entity
108+
render json: { error: result[:error] }, status: :unprocessable_content
109109
end
110110
end
111111

@@ -133,7 +133,7 @@ def destroy_batch
133133
error: 'No student IDs provided',
134134
error_type: :unprocessable_entity
135135
},
136-
status: :unprocessable_entity
136+
status: :unprocessable_content
137137
return
138138
end
139139

0 commit comments

Comments
 (0)