Sha256: 8d119f6a19904669ccabc993ff9f345d16f66cb1d2583ce738a6275f015b47fd

Contents?: true

Size: 1.19 KB

Versions: 17

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

class Comfy::Admin::Cms::Revisions::BaseController < Comfy::Admin::Cms::BaseController

  helper_method :record_path

  before_action :load_record
  before_action :load_revision, except: :index
  before_action :authorize

  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

  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 "comfy/admin/cms/revisions/show"
  end

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

protected

  def load_record
    raise "not implemented"
  end

  def load_revision
    @revision = @record.revisions.find(params[:id])
  rescue ActiveRecord::RecordNotFound
    flash[:danger] = I18n.t("comfy.admin.cms.revisions.not_found")
    redirect_to record_path
  end

  def record_path
    raise "no implemented"
  end

end

Version data entries

17 entries across 17 versions & 6 rubygems

Version Path
comfortable_mexican_sofa-2.0.19 app/controllers/comfy/admin/cms/revisions/base_controller.rb
PixelForce_ETS-0.0.2 app/controllers/comfy/admin/cms/revisions/base_controller.rb
PixelForce_ETS-0.0.1 app/controllers/comfy/admin/cms/revisions/base_controller.rb
kcyEtsTest2-0.0.4 app/controllers/comfy/admin/cms/revisions/base_controller.rb
kcyEtsTest2-0.0.3 app/controllers/comfy/admin/cms/revisions/base_controller.rb
kcyEtsTest2-0.0.2 app/controllers/comfy/admin/cms/revisions/base_controller.rb
kcyEtsTest2-0.0.1 app/controllers/comfy/admin/cms/revisions/base_controller.rb
kcyEtsTest-0.0.1 app/controllers/comfy/admin/cms/revisions/base_controller.rb
kcyEtsTest-2.2.19 app/controllers/comfy/admin/cms/revisions/base_controller.rb
ComfortableMexicanSofa-2.0.18 app/controllers/comfy/admin/cms/revisions/base_controller.rb
kcy1-1.0 app/controllers/comfy/admin/cms/revisions/base_controller.rb
comfortable_mexican_sofa-2.0.18 app/controllers/comfy/admin/cms/revisions/base_controller.rb
comfortable_mexican_sofa-2.0.17 app/controllers/comfy/admin/cms/revisions/base_controller.rb
comfortable_mexican_sofa-2.0.16 app/controllers/comfy/admin/cms/revisions/base_controller.rb
comfortable_mexican_sofa-2.0.15 app/controllers/comfy/admin/cms/revisions/base_controller.rb
comfortable_mexican_sofa-2.0.14 app/controllers/comfy/admin/cms/revisions/base_controller.rb
comfortable_mexican_sofa-2.0.13 app/controllers/comfy/admin/cms/revisions/base_controller.rb