Class: Admin::PageVersionsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#require_admin, #set_active_menu

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

#indexObject


3
4
5
6
# File 'app/controllers/admin/page_versions_controller.rb', line 3

def index
  @page = Page.find(params[:page_id])
  @page_versions = @page.versions.order(version: :desc).paginate(page: params[:page], per_page: 30)
end

#revertObject


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

def revert
  @page = Page.find(params[:page_id])
  @page_version = @page.versions.find(params[:id])
  if @page.revert_version(@page_version.version)
    redirect_to admin_page_versions_path(params[:page_id]), notice: "Wiki 内容已经撤销到了版本 #{@page_version.version}"
  else
    redirect_to admin_page_versions_path(params[:page_id]), alert: "版本撤销失败,原因: #{@page.errors.full_messages.join('<br />')}"
  end
end

#showObject


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

def show
  @page = Page.find(params[:page_id])
  @page_version = @page.versions.find(params[:id])
end