Class: Enki::Admin::UndoItemsController

Inherits:
BaseController show all
Defined in:
app/controllers/enki/admin/undo_items_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

#indexObject

[View source]

4
5
6
7
8
9
# File 'app/controllers/enki/admin/undo_items_controller.rb', line 4

def index
  @undo_items = UndoItem.find(:all,
    :order => 'created_at DESC',
    :limit => 50
  )
end

#undoObject

[View source]

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/enki/admin/undo_items_controller.rb', line 11

def undo
  item = UndoItem.find(params[:id])
  begin
    object = item.process!

    respond_to do |format|
      format.html {
        flash[:notice] = item.complete_description
        redirect_to(:back)
      }
      format.json {
        render :json => {
          :message => item.complete_description,
          :obj     => object.attributes
        }
      }
    end
  rescue UndoFailed
    msg = "Could not undo, would result in an invalid state (i.e. a comment with no post)"
    respond_to do |format|
      format.html {
        flash[:notice] = msg
        redirect_to(:back)
      }
      format.json {
        render :json => { :message => msg }
      }
    end
  end
end