Why does the each method require the value it looped to be assigned to a variable?

Viewed 73

Working on Rails and found lack of knowledge in my understanding of the each method.

Not sure why the each method requires the variable |message|

<% @messages.each do |message| %>
    <h2><%= message.title %></h2>
    <%= link_to "View Message", message_path(message), class: "btn btn-default" %>
<% end %>
3 Answers
Related