Class: CommentsController

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

Overview

Comments

Instance Method Summary collapse

Instance Method Details

#checkObject

post /comments/check



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

def check
  @entity = Comment.instance_for_check(params[:entity_id], entity_parameters)

  render 'shared/forms/check'
end

#createObject

post /comments



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

def create
  if params.key?(:agree)
    emulate_creation
  else
    create_comment
  end
end

#destroyObject

delete /comments/:id



40
41
42
43
44
45
# File 'app/controllers/comments_controller.rb', line 40

def destroy
  if @entity.update deleted: true
    flash[:notice] = t('comments.destroy.success')
  end
  redirect_to(@entity.commentable || admin_comments_path)
end

#editObject

get /comments/:id/edit



27
28
# File 'app/controllers/comments_controller.rb', line 27

def edit
end

#showObject

get /comments/:id



48
49
50
# File 'app/controllers/comments_controller.rb', line 48

def show
  redirect_to(admin_comment_path(id: params[:id]))
end

#updateObject

patch /comments/:id



31
32
33
34
35
36
37
# File 'app/controllers/comments_controller.rb', line 31

def update
  if @entity.update entity_parameters
    form_processed_ok(admin_comment_path(id: @entity.id))
  else
    form_processed_with_error(:edit)
  end
end