Class: Bbs::CommentsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#logged_in?

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
# File 'app/controllers/bbs/comments_controller.rb', line 6

def create
  @comment = @topic.comments.build(comment_params)

  if @comment.save
    redirect_to bbs.topic_comments_path(@topic), notice: t('.success')
  else
    redirect_back fallback_location: bbs.topic_comments_path(@topic), alert: @comment.errors.full_messages
  end
end

#indexObject



16
17
18
19
# File 'app/controllers/bbs/comments_controller.rb', line 16

def index
  @comment = @topic.comments.build
  @comments = comments
end