Class: Requests::CommentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Requests::CommentsController
- Defined in:
- app/controllers/requests/comments_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
15 16 17 18 19 |
# File 'app/controllers/requests/comments_controller.rb', line 15 def create @request.comments.create(description: params[:comment], user_id: current_user.id) @comments = @request.comments render partial: 'list', locals: { commentable: @request, visible: true } end |
#destroy ⇒ Object
21 22 23 24 25 26 |
# File 'app/controllers/requests/comments_controller.rb', line 21 def destroy comment = Comment.find(params[:id]) comment.destroy if comment.present? @comments = @request.comments render partial: 'list', locals: { commentable: @request, visible: true } end |
#index ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'app/controllers/requests/comments_controller.rb', line 5 def index commentables = [@request, @request.asset, @request.asset&.labware].compact @comments = Comment.where(commentable: commentables).order('created_at ASC') if request.xhr? render partial: 'simple_list', locals: { descriptions: @comments.pluck(:description) } else # Perform default end end |