Class: V2Users::Reviews::PhotosController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/v2_users/reviews/photos_controller.rb

Overview

typed: ignore

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#reservationObject

Returns the value of attribute reservation.



8
9
10
# File 'app/controllers/v2_users/reviews/photos_controller.rb', line 8

def reservation
  @reservation
end

#reviewObject

Returns the value of attribute review.



8
9
10
# File 'app/controllers/v2_users/reviews/photos_controller.rb', line 8

def review
  @review
end

Instance Method Details

#createObject



10
11
12
13
14
15
# File 'app/controllers/v2_users/reviews/photos_controller.rb', line 10

def create
  return render json: { success: false } if reservation.id != review.reservation_id

  rp = ReviewPhoto.create!(photo: params.require(:file), review_id: review.id)
  render json: { success: true, id: rp.id }
end

#destroyObject



17
18
19
20
21
# File 'app/controllers/v2_users/reviews/photos_controller.rb', line 17

def destroy
  rp = ReviewPhoto.find(params.require(:id))
  rp.destroy!
  render json: { success: true }
end