Pass parameters to partial in rails

2023-10-16 rails

Here's how to pass parameters to partial in rails.

<%= render "test_locals", test: "Hello, world!" %>

You can use the variable in the partial.

<%= test %>  # => Hello, world!

You can also use the local_assigns variable.

<%= local_assigns %>

By the way, The first example(using @zone) on the official document did not work for me.

https://guides.rubyonrails.org/layouts_and_rendering.html