Created
August 17, 2019 06:03
-
-
Save SunDi3yansyah/46161d2b9576017b826e249951128261 to your computer and use it in GitHub Desktop.
Example API for upload image in QuillJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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