Class: Articles::CoverImagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Articles::CoverImagesController
- Defined in:
- app/controllers/postnhost/articles/cover_images_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/postnhost/articles/cover_images_controller.rb', line 6 def create file = params[:file] if file.present? @article.cover_image = file if @article.save render json: { url: @article.cover_image.url }, status: :ok else render json: { error: @article.errors..join(", ") }, status: :unprocessable_content end else render json: { error: "No file provided" }, status: :bad_request end end |
#destroy ⇒ Object
22 23 24 25 26 27 |
# File 'app/controllers/postnhost/articles/cover_images_controller.rb', line 22 def destroy # HACK: to bypass carrierwave image removal from bucket to keep the version history @article.update_column(:cover_image, nil) head :no_content end |