Class: Dorsale::CommentsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#filters_jar, #scope

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/dorsale/comments_controller.rb', line 10

def create
  @comment ||= scope.new(comment_params_for_create)

  authorize @comment, :create?

  if @comment.save
    notify_attachable!(:create)
    render_comment
  else
    render_nothing
  end
end

#destroyObject



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

def destroy
  authorize @comment, :delete?

  @comment.destroy!
  notify_attachable!(:delete)

  render_nothing
end

#editObject



23
24
25
# File 'app/controllers/dorsale/comments_controller.rb', line 23

def edit
  authorize @comment, :update?
end

#updateObject



27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/dorsale/comments_controller.rb', line 27

def update
  authorize @comment, :update?

  if @comment.update(comment_params_for_update)
    notify_attachable!(:update)
    render_comment
  else
    render_form
  end
end