Class: Interact::CommentsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/interact/comments_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @comment = Comment.new(comment_params)

  if @comment.save
    render :show, status: :created
  else
    process_errors(@comment)
  end
end

#destroyObject



31
32
33
# File 'app/controllers/interact/comments_controller.rb', line 31

def destroy
  @comment.destroy
end

#indexObject



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

def index
  q_params = {}
  q_params.merge! params.permit(:commentable_type, :commentable_id)
  @comments = Comment.default_where(q_params).page(params[:page]).per(params[:per])
end

#showObject



10
11
# File 'app/controllers/interact/comments_controller.rb', line 10

def show
end

#updateObject



23
24
25
26
27
28
29
# File 'app/controllers/interact/comments_controller.rb', line 23

def update
  if @comment.update(comment_params)
    render 'show'
  else
    render json: @comment.errors, status: :unprocessable_entity
  end
end