Skip to content

Commit 8382c91

Browse files
committed
Refactor student removal so it's common between #destroy and #destroy_batch without coupling those methods.
1 parent c305c22 commit 8382c91

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

app/controllers/api/school_students_controller.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ def update
110110
end
111111

112112
def destroy
113-
params[:student_ids] = [params[:id]]
114-
destroy_batch
113+
remove_students([params[:id]])
115114
end
116115

117116
def destroy_batch
@@ -126,6 +125,12 @@ def destroy_batch
126125
return
127126
end
128127

128+
remove_students(student_ids)
129+
end
130+
131+
private
132+
133+
def remove_students(student_ids)
129134
# Invoke StudentRemovalService
130135
service = StudentRemovalService.new(
131136
students: student_ids,
@@ -148,8 +153,6 @@ def destroy_batch
148153
end
149154
end
150155

151-
private
152-
153156
def school_student_params
154157
params.require(:school_student).permit(:username, :password, :name)
155158
end

0 commit comments

Comments
 (0)