Class: Talkie::CommentsController

Inherits:
TalkieController show all
Defined in:
app/controllers/talkie/comments_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/talkie/comments_controller.rb', line 7

def create
  @comment = Talkie::Comment.new(comment_params)
  @comment.creator = current_user

  respond_to do |format|
    if @comment.save
      make_child_comment if reply?
      format.html { redirect_to Talkie.success_redirect_to.call(main_app, @comment.commentable),
                                notice: t('talkie.controllers.comments.flash.success') }
      format.js
    else
      format.html { redirect_back fallback_location: Talkie.fail_redirect_to.call(main_app),
                    notice: t('talkie.controllers.comments.flash.error') }
      format.js
    end
  end
end

#destroyObject



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

def destroy
  current_comment.destroy
  redirect_to main_app.polymorphic_path(current_comment.commentable)
end