Forked from
PortalMEC / portalmec
1078 commits behind the upstream repository.
-
Marcela Ribeiro de Oliveira authoredMarcela Ribeiro de Oliveira authored
subjectable_controller.rb 705 B
module SubjectableController
extend ActiveSupport::Concern
included do
before_action :authenticate_user!, only: [:subjecting, :unsubjecting]
end
# POST /v1/learning_objects/1/subjects
# POST /v1/learning_objects/1/subjects.json
def subjecting
subjectable.add_subjects(ids: params[:subjects])
render json: subjectable.subjects, status: :created
end
# DELETE /v1/learning_objects/1/subjects
# DELETE /v1/learning_objects/1/subjects.json
def unsubjecting
subjectable.remove_subjects(ids: params[:subjects])
render json: subjectable.subjects, status: :ok
end
protected
def subjectable
raise NotImplementedError
end
end