Class: Polivalente::CommentsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



3
4
5
6
7
8
# File 'app/controllers/polivalente/comments_controller.rb', line 3

def create
  @comment = @commentable.comments.new(comment_params)
  @comment.user = current_user
  @comment.save
  redirect_to @commentable, notice: "Your comment was successfully posted."
end

#destroyObject



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

def destroy
  @comment = Comment.where(user_id: current_user.id).find(params[:id])

  @comment.destroy if @comment

  respond_to do |format|
    format.html { redirect_back(fallback_location: @commentable) }
    format.json { head :no_content }
  end
end