Complete the code to render a partial named '_menu.html.erb' inside a view.
<%= render [1] %>In Rails, to render a partial named '_menu.html.erb', you use render 'menu'. This tells Rails to look for the partial with that name.
Complete the code to render a partial named '_item.html.erb' and pass a local variable 'product' to it.
<%= render partial: 'item', locals: [1] %>
To pass local variables to a partial, you use the locals option with a hash. The key is the variable name inside the partial, and the value is the data you pass.
Fix the error in rendering a collection of @products with the partial '_product.html.erb'.
<%= render [1] %>To render a collection of objects with a partial, use render partial: 'product', collection: @products. This renders the partial for each item in the collection.
Fill both blanks to render a partial '_comment.html.erb' for each comment in @comments and pass each comment as a local variable named 'comment'.
<%= render partial: [1], collection: [2], locals: { comment: comment } %>
The partial name should be singular 'comment' and the collection is the array @comments. This renders the partial for each comment and passes it as a local variable.
Fill all three blanks to render a partial '_user.html.erb' for each user in @users, pass each user as 'user', and add a spacer partial '_spacer.html.erb' between each user.
<%= render partial: [1], collection: [2], locals: { user: user }, [3]: 'spacer' %>
Use partial: 'user' for the user partial, collection: @users for the list, and spacer_template: 'spacer' to add the spacer partial between items.