Class: Rankit::CommentsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#after_sign_out_path_for

Instance Method Details

#createObject



15
16
17
18
19
20
21
# File 'app/controllers/rankit/comments_controller.rb', line 15

def create
  @comment = @rankable.comments.build(comment_params)
  @comment.user = current_user
  if @comment.save
    redirect_to rankit.rankable_comments_path(@rankable)
  end
end

#indexObject



7
8
9
# File 'app/controllers/rankit/comments_controller.rb', line 7

def index
  @comments = @rankable.comments.order('created_at DESC')
end

#newObject



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

def new
  @comment = Rankit::Comment.new
end