class V1::LearningObjects::PublishesController < ApplicationController before_action :set_learning_object before_action :authorize! # POST /learning_objects/:id/publish def create return render status: :ok if @learning_object.published? publisher = LearningObjectPublisher.new(DspaceService.create_client) publisher.publish @learning_object render status: :ok end private # Use callbacks to share common setup or constraints between actions. def set_learning_object @learning_object = LearningObject.find(params[:id]) end def authorize! authorize(@learning_object || LearningObject.new, :update?) end # Never trust parameters from the scary internet, only allow the white list through. def publish_params params.permit(:id) end end