Sha256: 304f4c7c1411b134b18b56d660097c05f8c5137ef1d5686eb0560a5fb90b2088

Contents?: true

Size: 763 Bytes

Versions: 31

Compression:

Stored size: 763 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  module ResourceVersionsConcern
    extend ActiveSupport::Concern

    included do
      helper Decidim::TraceabilityHelper
      helper_method :current_version, :versioned_resource

      def show
        raise ActionController::RoutingError, "Not found" unless current_version
      end

      private

      # Overwrite this method in your controller to define how to find the
      # versioned resource.
      def versioned_resource
        raise StandardError, "Not implemented"
      end

      def current_version
        return nil unless params[:id].to_i.positive?

        @current_version ||= versioned_resource.versions[params[:id].to_i - 1]
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
decidim-core-0.29.1 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.28.4 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.27.9 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.29.0 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.28.3 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.27.8 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.29.0.rc4 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.29.0.rc3 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.29.0.rc2 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.29.0.rc1 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.28.2 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.27.7 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.28.1 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.27.6 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.26.10 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.26.9 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.28.0 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.27.5 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.28.0.rc5 app/controllers/concerns/decidim/resource_versions_concern.rb
decidim-core-0.28.0.rc4 app/controllers/concerns/decidim/resource_versions_concern.rb