Class: Admin::CommentsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#fresh_when, #redirect_back_or_default, #redirect_referrer_or_default, #render_403, #render_404, #render_optional_error_file, #require_user, #set_active_menu, #set_locale, #set_seo_meta, #store_location, #unread_notify_count

Instance Method Details

#destroyObject


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

def destroy
  @comment = Comment.find(params[:id])
  @comment.destroy
  respond_with do |format|
    format.html { redirect_to admin_comments_path }
    format.js { render layout: false }
  end
end

#editObject


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

def edit
  @comment = Comment.find(params[:id])
end

#indexObject


5
6
7
# File 'app/controllers/admin/comments_controller.rb', line 5

def index
  @comments = Comment.recent.includes(:user).paginate(page: params[:page], per_page: 20)
end

#updateObject


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

def update
  @comment = Comment.find(params[:id])

  if @comment.update_attributes(params[:comment].permit!)
    redirect_to admin_comments_path(@admin_comment), notice: 'Comment was successfully updated.'
  else
    render action: 'edit'
  end
end