Class: Collavre::Comments::SnapshotsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Collavre::Comments::SnapshotsController
- Includes:
- CommentScoping
- Defined in:
- app/controllers/collavre/comments/snapshots_controller.rb
Instance Method Summary collapse
-
#index ⇒ Object
GET /creatives/:creative_id/comments/snapshots.
-
#restore ⇒ Object
POST /creatives/:creative_id/comments/snapshots/:id/restore.
Instance Method Details
#index ⇒ Object
GET /creatives/:creative_id/comments/snapshots
12 13 14 15 16 17 18 |
# File 'app/controllers/collavre/comments/snapshots_controller.rb', line 12 def index snapshots = @creative.comment_snapshots .restorable .order(created_at: :desc) render json: snapshots.map { |s| snapshot_json(s) } end |
#restore ⇒ Object
POST /creatives/:creative_id/comments/snapshots/:id/restore
21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/collavre/comments/snapshots_controller.rb', line 21 def restore service = CommentSnapshotRestoreService.new(snapshot: @snapshot, user: Current.user) recreated = service.call render json: { message: I18n.t("collavre.comment_snapshots.restored"), count: recreated.size } rescue CommentSnapshotRestoreService::RestoreError => e render json: { error: e. }, status: :unprocessable_entity end |