Sha256: 2dd95f5a89c48181e7e3b77741fc082330c23705db58deecb5ae0782635283db

Contents?: true

Size: 662 Bytes

Versions: 1

Compression:

Stored size: 662 Bytes

Contents

module ActiveAdminVersioning
  module Extension
    module ResourceController
      def self.included(base)
        base.before_action(:set_paper_trail_whodunnit)
      end

      def show
        page = params[:page].to_i
        @versions = resource.versions.reorder(id: :desc, created_at: :desc).page(params[:page]).per(1)
        @version_number = page > 0 ? @versions.total_count - (page - 1) : @versions.total_count
        set_resource_ivar(@versions[0].reify) if @versions.present?
        show!
      end

      protected

      def user_for_paper_trail
        current_admin_user.try(:id) || t("views.version.unknown_user")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_admin_versioning-0.1.0 lib/active_admin_versioning/extension/resource_controller.rb