Class: Studies::CommentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Studies::CommentsController
- Defined in:
- app/controllers/studies/comments_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
12 13 14 15 16 |
# File 'app/controllers/studies/comments_controller.rb', line 12 def create @study.comments.create(description: params[:comment], user_id: current_user.id) @comments = @study.comments render partial: 'list', locals: { commentable: @study, visible: true } end |
#destroy ⇒ Object
18 19 20 21 22 23 |
# File 'app/controllers/studies/comments_controller.rb', line 18 def destroy comment = Comment.find(params[:id]) comment.destroy if comment.present? @comments = @study.comments render partial: 'list', locals: { commentable: @study, visible: true } end |
#index ⇒ Object
8 9 10 |
# File 'app/controllers/studies/comments_controller.rb', line 8 def index @comments = @study.comments.order(:created_at) end |