I want to iterate through an array of objects
<% @users.each do |user| %>
<%= render "member_list" %>
<% end %>
My question is how do I pass the user object to the partial, and how do I reference it in the partial. I know how to do it if it’s just a single object, but I don’t know how to pass the single object from the array to it.
I tried passing user to it and reference user in the partial, but it doesn’t recognize user in the partial.
You might do it without loop – pass it as a
:collectionparameter. To use a custom local variable name within the partial, specify the:asoption in the call to the partial:With this change, you can access an instance of the
@userscollection as thememberlocal variable within the partial.