Can I render a partial from a view?

I want to make a helper for outputting tables, with the table body rows outputted via partials.

Here’s what I’ve wrote so far:

module Web
  module Helpers
    module Table
      def table(data, body_partial)
        html.table(class: TailwindConstants::TABLE) do
          thead # TODO: add table head
          tbody do
            data.map do |obj|
              tr { render partial: body_partial, object: obj }
            end
          end
        end
      end
    end
  end
end

But when I call it from the template, I get an error: wrong number of arguments (given 1, expected 0)

I suspect this is because the view’s render method is different from the render method available in templates (used to render partials).

Is there a way to render a partial from a view/helper? Thank you.

1 Like

@art-solopov Sorry, but you can’t render a partial from an HTML helper.