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