Class: Blogr::CommentsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



26
27
28
29
30
31
32
33
34
# File 'app/controllers/blogr/comments_controller.rb', line 26

def create
  @comment = Comment.new(tag_params)

  if @comment.save
    redirect_to @comment, notice: 'Comment was successfully created.'
  else
    render action: 'new'
  end
end

#destroyObject



44
45
46
47
# File 'app/controllers/blogr/comments_controller.rb', line 44

def destroy
  @comment.destroy
  redirect_to comments_path, notice: 'Comment was successfully destroyed.'
end

#editObject



22
23
24
# File 'app/controllers/blogr/comments_controller.rb', line 22

def edit
  @title = "Editing Comment by '#{@comment.author_name}'"
end

#indexObject



8
9
10
11
# File 'app/controllers/blogr/comments_controller.rb', line 8

def index
  @title = "Comments"
  @comments = Blogr::Comment.all
end

#newObject



17
18
19
20
# File 'app/controllers/blogr/comments_controller.rb', line 17

def new
  @comment = Comment.new
  @title = "New Comment"
end

#showObject



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

def show
  @title = "Comment ##{@comment.id}"
end

#updateObject



36
37
38
39
40
41
42
# File 'app/controllers/blogr/comments_controller.rb', line 36

def update
  if @comment.update(tag_params)
    redirect_to @comment, notice: 'Comment was successfully updated.'
  else
    render action: 'edit'
  end
end