Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UploadsController < ApplicationController
- def index
- @upload = Upload.new
- end
- def create
- @upload = Upload.new(upload_params)
- if @upload.save
- render json: { message: "success", uploadId: @upload.id }, status: 200
- else
- render json: { error: @upload.errors.full_messages.join(", ") }, status: 400
- end
- end
- def destroy
- @upload = Upload.find(params[:id])
- if @upload.destroy
- render json: { message: "file deleted from server" }
- else
- render json: { message: @document.errors.full_messages.join(", ") }
- end
- end
- private
- def upload_params
- params.require(:upload).permit(:name, :email, :document)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement