Class: Labware::CommentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Labware::CommentsController
- Defined in:
- app/controllers/labware/comments_controller.rb
Overview
Add comments to labware
Constant Summary
Constants included from FlashTruncation
FlashTruncation::STRING_OVERHEAD
Instance Method Summary collapse
Methods inherited from ApplicationController
#block_api_access, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!
Methods included from FlashTruncation
#max_flash_size, #truncate_flash, #truncate_flash_array
Instance Method Details
#create ⇒ Object
16 17 18 19 20 |
# File 'app/controllers/labware/comments_controller.rb', line 16 def create @labware.comments.create(description: params[:comment], user: current_user) @comments = @labware.comments render partial: 'list', locals: { commentable: @labware, visible: true, labware: @labware } end |
#destroy ⇒ Object
22 23 24 25 26 27 |
# File 'app/controllers/labware/comments_controller.rb', line 22 def destroy comment = Comment.find(params[:id]) comment.destroy if comment.present? @comments = @labware.comments render partial: 'list', locals: { commentable: @labware, visible: true, labware: @labware } end |
#index ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/controllers/labware/comments_controller.rb', line 7 def index @comments = @labware.comments.order(created_at: :asc) if request.xhr? render partial: 'simple_list', locals: { descriptions: @comments.pluck(:description) } else render :index end end |