Class: Railspress::Api::V1::PostHeaderImagesController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Railspress::Api::V1::PostHeaderImagesController
- Includes:
- Concerns::PostSerialization
- Defined in:
- app/controllers/railspress/api/v1/post_header_images_controller.rb
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
Instance Method Details
#destroy ⇒ Object
34 35 36 37 |
# File 'app/controllers/railspress/api/v1/post_header_images_controller.rb', line 34 def destroy @post.header_image.purge if @post.header_image.attached? head :no_content end |
#show ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/railspress/api/v1/post_header_images_controller.rb', line 12 def show return render_error("Header image not found.", status: :not_found) unless @post.header_image.attached? render json: { data: { post_id: @post.id, header_image: serialize_header_image(@post), header_image_focal_point: serialize_header_image_focal_point(@post) } } end |
#update ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/railspress/api/v1/post_header_images_controller.rb', line 24 def update image = header_image_param return render_error("Either image or signed_blob_id is required.", status: :unprocessable_content) if image.blank? @post.header_image.attach(image) render json: { data: serialize_post(@post.reload) } rescue ActiveSupport::MessageVerifier::InvalidSignature, ActiveRecord::RecordNotFound render_error("Invalid signed blob id.", status: :unprocessable_content) end |