Sha256: 5f3bff4021bb21831d7fe36c0bae11377ea179d8addc895712c302cd534a845d

Contents?: true

Size: 763 Bytes

Versions: 4

Compression:

Stored size: 763 Bytes

Contents

module Chive
  module ApplicationHelper
    # Needed to fix polymorphic_mappings.
    # @see https://github.com/rails/rails/issues/31325#issuecomment-560135329
    def method_missing(method, *args, &block)
      if method.to_s.end_with?("_path", "_url")
        if main_app.respond_to?(method)
          main_app.send(method, *args)
        else
          super
        end
      else
        super
      end
    end

    # Needed to fix polymorphic_mappings.
    # @see https://github.com/rails/rails/issues/31325#issuecomment-560135329
    def respond_to?(method)
      if method.to_s.end_with?("_path", "_url")
        if main_app.respond_to?(method)
          true
        else
          super
        end
      else
        super
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chive-0.2.3 app/helpers/chive/application_helper.rb
chive-0.2.2 app/helpers/chive/application_helper.rb
chive-0.2.1 app/helpers/chive/application_helper.rb
chive-0.2.0 app/helpers/chive/application_helper.rb