Class: Occams::Admin::Cms::Revisions::BaseController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/occams/admin/cms/revisions/base_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



10
11
12
13
14
15
16
17
# File 'app/controllers/occams/admin/cms/revisions/base_controller.rb', line 10

def index
  revision = @record.revisions.order(created_at: :desc).first
  if revision
    redirect_to action: :show, id: revision.id
  else
    redirect_to record_path
  end
end

#revertObject



26
27
28
29
30
# File 'app/controllers/occams/admin/cms/revisions/base_controller.rb', line 26

def revert
  @record.restore_from_revision(@revision)
  flash[:success] = I18n.t('occams.admin.cms.revisions.reverted')
  redirect_to record_path
end

#showObject



19
20
21
22
23
24
# File 'app/controllers/occams/admin/cms/revisions/base_controller.rb', line 19

def show
  @current_content    = @record.revision_fields.each_with_object({}) { |f, c| c[f] = @record.send(f) }
  @versioned_content  = @record.revision_fields.each_with_object({}) { |f, c| c[f] = @revision.data[f] }

  render 'occams/admin/cms/revisions/show'
end