Class: Spotlight::VersionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/spotlight/versions_controller.rb

Overview

Controller for reverting to historical versions of e.g. pages

Instance Method Summary collapse

Instance Method Details

#revert ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/spotlight/versions_controller.rb', line 11

def revert
  obj = @version.reify
  if obj && authorize!(:manage, obj)
    if obj.save
      redirect_to [obj.exhibit, obj], flash: { html_safe: true }, notice: undo_link
    else
      redirect_to [obj.exhibit, obj], flash: { html_safe: true }, notice: view_context.t(:'spotlight.versions.undo_error')
    end
  else
    redirect_back_or_to(main_app.root_url, flash: { html_safe: true }, notice: view_context.t(:'spotlight.versions.undo_error'))
  end
end