Skip to content

Instantly share code, notes, and snippets.

@SunDi3yansyah
Created August 17, 2019 06:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SunDi3yansyah/46161d2b9576017b826e249951128261 to your computer and use it in GitHub Desktop.
Save SunDi3yansyah/46161d2b9576017b826e249951128261 to your computer and use it in GitHub Desktop.
Example API for upload image in QuillJS
class ImagesController < ActionController::Base
skip_before_action :verify_authenticity_token
def create
@image = Image.new(image_params)
if @image.save
render json: { url: @image.image_url(:original) }, status: 201
else
render json: { message: @image.errors.full_messages.first }, status: 422
end
rescue => exception
render json: { message: exception.message }, status: 500
end
private
def image_params
params.require(:image).permit(:image)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment