instance method partial_path

Ruby on Rails 5.2.8.1

Since v3.2.22.5 Last seen in v6.0.6 Private

Available in: v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6

Signature

partial_path(object = @object)

Obtains the path to where the object’s partial is located. If the object responds to to_partial_path, then to_partial_path will be called and will provide the path. If the object does not respond to to_partial_path, then an ArgumentError is raised.

If prefix_partial_path_with_controller_namespace is true, then this method will prefix the partial paths with a namespace.

Parameters

object opt = @object
Source
# File actionview/lib/action_view/renderer/partial_renderer.rb, line 477
      def partial_path(object = @object)
        object = object.to_model if object.respond_to?(:to_model)

        path = if object.respond_to?(:to_partial_path)
          object.to_partial_path
        else
          raise ArgumentError.new("'#{object.inspect}' is not an ActiveModel-compatible object. It must implement :to_partial_path.")
        end

        if @view.prefix_partial_path_with_controller_namespace
          prefixed_partial_names[path] ||= merge_prefix_into_object_path(@context_prefix, path.dup)
        else
          path
        end
      end

Defined in actionview/lib/action_view/renderer/partial_renderer.rb line 477 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::PartialRenderer

Type at least 2 characters to search.

↑↓ navigate · open · esc close