Rails outputting object hash

后端 未结 1 1634
后悔当初
后悔当初 2021-01-23 11:12

This is interesting. I have some view code that looks like this:

    <%= @cause.updates.each do |update| %>
      
1条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-23 12:03

    Your using <%= %> where you need <% %>. Since each returns the object it iterated over, once you are done iterating over updates, updates is returned and output to the HTML

    <% @cause.updates.each do |update| # remove the = at the beginning of this line %>
      

    <%= update.update_text %>

    <% end %>

    0 讨论(0)
提交回复
热议问题