Sha256: 84850ace988315cb97584f81811d5c35ae05cbbcd822b4eac5ed9bb52c6d7bcc

Contents?: true

Size: 814 Bytes

Versions: 1

Compression:

Stored size: 814 Bytes

Contents

module Cmor
  module Files
    # Example:
    #
    #     # app/controllers/application_controller.rb
    #     class ApplicationController < ActionController::Base
    #       view_helper Cmor::Files::ApplicationViewHelper, as: :files_helper
    #     end
    #
    class ApplicationViewHelper < Rao::ViewHelper::Base
      # Example:
      #
      #     # app/views/layouts/application.html.haml
      #     = files_helper(self).render_download(identifier: 'Quick reference manual')
      #
      def render_file(identifier:)
        resource = Cmor::Files::FileDetail.published.where(identifier: identifier).first
        if resource.nil?
          "Could not find published file detail with identifier: '#{identifier}'."
        else
          render resource: resource
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cmor_files-0.0.54.pre app/view_helpers/cmor/files/application_view_helper.rb