class Admin::Pages::VersionsController

Show old versions of Pages

Public Instance Methods

destroy() click to toggle source
# File app/controllers/admin/pages/versions_controller.rb, line 19
def destroy
  @version = Page::Version.find(params[:id])
  @page = @version.versioned
  @version.destroy
  flash[:notice] = "Deleted #{@version.versioned.title}"
  redirect_to edit_admin_page_path(@version.versioned)
end
edit() click to toggle source
# File app/controllers/admin/pages/versions_controller.rb, line 6
def edit
  @version = Page::Version.find(params[:id])
  @page = @version.versioned
  # The _new_ version of the old parent, which may be confusing
  @parent = Page.find(@version.versioned.parent_id) if @version.versioned.parent_id
end
revert() click to toggle source

Revert to version

# File app/controllers/admin/pages/versions_controller.rb, line 28
def revert
  version = Page::Version.find(params[:id])
  page = version.versioned

  begin
    ActiveRecord::Base.lock_optimistically = false
    page.revert_to! version.number
  ensure
    ActiveRecord::Base.lock_optimistically = true
  end

  expire_cache
  flash[:notice] = "Reverted #{page.title} to version from #{version.updated_at.to_s(:long)}"
  redirect_to edit_admin_page_path(page)
end
show() click to toggle source
# File app/controllers/admin/pages/versions_controller.rb, line 13
def show
  @version = Page::Version.find(params[:id])
  @page = @version.versioned
  render :inline => @version.versioned.body, :layout => "application"
end