Class: Enki::Admin::CommentsController

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

Instance Method Summary collapse

Methods included from HostHelper

#render_enki

Methods included from UrlHelper

#author_link, #post_comments_path, #post_path

Methods included from TagHelper

#linked_tag_list

Methods included from PostsHelper

#more_content?

Methods included from PageTitleHelper

#archives_title, #html_title, #page_title, #post_title, #posts_title

Methods included from NavigationHelper

#category_links_for_navigation, #class_for_tab, #page_links_for_navigation

Methods included from FormHelper

#admin_form_for

Methods included from DateHelper

#format_comment_date, #format_month, #format_post_date

Methods included from Enki::ApplicationHelper

#author, #comments?, #format_comment_error, #paginated, #tags?

Instance Method Details

#destroyObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/enki/admin/comments_controller.rb', line 27

def destroy
  undo_item = @comment.destroy_with_undo

  respond_to do |format|
    format.html do
      flash[:notice] = "Deleted comment by #{@comment.author}"
      redirect_to admin_comments_url
    end
    format.json {
      render :json => {
        :undo_path    => undo_admin_undo_item_path(undo_item),
        :undo_message => undo_item.description,
        :comment      => @comment.attributes
      }.to_json
    }
  end
end

#indexObject



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

def index
  @comments = Comment.order("comments.created_at DESC").includes(:post).paginated(params)
end

#showObject



10
11
12
13
14
15
16
# File 'app/controllers/enki/admin/comments_controller.rb', line 10

def show
  respond_to do |format|
    format.html {
      render :partial => 'comment', :locals => {:comment => @comment} if request.xhr?
    }
  end
end

#updateObject



18
19
20
21
22
23
24
25
# File 'app/controllers/enki/admin/comments_controller.rb', line 18

def update
  if @comment.update_attributes(params[:comment])
    flash[:notice] = "Updated comment by #{@comment.author}"
    redirect_to [:admin, :comments]
  else
    render :action => 'show'
  end
end