Sha256: dfc67beb3704be2f35ce5e13eb2f269c678b503155f1aa387521f779fc7620f5

Contents?: true

Size: 813 Bytes

Versions: 18

Compression:

Stored size: 813 Bytes

Contents

# frozen_string_literal: true

module Renalware
  class ApplicationComponent < ViewComponent::Base
    include Renalware::Engine.routes.url_helpers
    include Pundit::Helper
    delegate :current_user, :policy, to: :helpers

    # Not sure why include Renalware::Engine.routes.url_helpers does not make the
    # engine urls visible in the views (seems to resolve alwatys to /assets?..)
    # so we expose routes here so inside a component html file we can use
    # e.g. renalware.bookmarks_path
    def renalware
      Renalware::Engine.routes.url_helpers
    end

    # Added this helper as I can't seem to get the Pundit #policy helper to be included
    # in the context when rendering a component template.
    def policy(record)
      current_user && Pundit.policy(current_user, record)
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/components/renalware/application_component.rb
renalware-core-2.1.0 app/components/renalware/application_component.rb
renalware-core-2.0.167 app/components/renalware/application_component.rb
renalware-core-2.0.166 app/components/renalware/application_component.rb
renalware-core-2.0.165 app/components/renalware/application_component.rb
renalware-core-2.0.164 app/components/renalware/application_component.rb
renalware-core-2.0.163 app/components/renalware/application_component.rb
renalware-core-2.0.162 app/components/renalware/application_component.rb
renalware-core-2.0.161 app/components/renalware/application_component.rb
renalware-core-2.0.160 app/components/renalware/application_component.rb
renalware-core-2.0.159 app/components/renalware/application_component.rb
renalware-core-2.0.158 app/components/renalware/application_component.rb
renalware-core-2.0.157 app/components/renalware/application_component.rb
renalware-core-2.0.156 app/components/renalware/application_component.rb
renalware-core-2.0.155 app/components/renalware/application_component.rb
renalware-core-2.0.153 app/components/renalware/application_component.rb
renalware-core-2.0.152 app/components/renalware/application_component.rb
renalware-core-2.0.151 app/components/renalware/application_component.rb