Class: Batches::CommentsController

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

Instance Method Summary collapse

Instance Method Details

#createObject


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

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


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

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

#indexObject


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

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