Sha256: 79b6948b7bc175123b1473d815d33335adbd5712b5503afbdb10e5df98b5a7a8
Contents?: true
Size: 1.16 KB
Versions: 47
Compression:
Stored size: 1.16 KB
Contents
module Spotlight ## # Controller for reverting to historical versions of e.g. pages class VersionsController < Spotlight::ApplicationController before_action :authenticate_user! load_and_authorize_resource class: 'PaperTrail::Version' 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 fallback_location: main_app.root_url, flash: { html_safe: true }, notice: view_context.t(:'spotlight.versions.undo_error') end end private def undo_link return unless can? :manage, @version link_name = if params[:redo] == 'true' view_context.t(:'spotlight.versions.undo') else view_context.t(:'spotlight.versions.redo') end view_context.link_to(link_name, revert_version_path(@version.next, redo: !params[:redo]), method: :post) end end end
Version data entries
47 entries across 47 versions & 1 rubygems