Class: Batches::CommentsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/batches/comments_controller.rb

Overview

rubocop:todo Style/Documentation

Instance Method Summary collapse

Instance Method Details

#createObject


12
13
14
15
16
# File 'app/controllers/batches/comments_controller.rb', line 12

def create
  @batch.comments.create(description: params[:comment], user_id: current_user.id)
  @comments = @batch.comments
  render partial: 'list', locals: { commentable: @batch, visible: true }
end

#destroyObject


18
19
20
21
22
23
# File 'app/controllers/batches/comments_controller.rb', line 18

def destroy
  comment = Comment.find(params[:id])
  comment.destroy if comment.present?
  @comments = @batch.comments
  render partial: 'list', locals: { commentable: @batch, visible: true }
end

#indexObject


8
9
10
# File 'app/controllers/batches/comments_controller.rb', line 8

def index
  @comments = @batch.comments.order(created_at: :asc)
end