1

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

    <%= @cause.updates.each do |update| %>
      <div class="streamComment group">

      <img class="userPhoto" src="<%= update.user.avatar.url %>">

      <p class="userComment"><%= update.update_text %></p>
      </div>
    <% end %>

Between the end of the paragraph tag and the end of the div tag, rails is outputting the hash of the update object i.e. "<#Update 0x6993934ksf>" when nothing exists there in the view. What could be causing this?

1 Answer 1

5

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 %>
  <div class="streamComment group">

  <img class="userPhoto" src="<%= update.user.avatar.url %>">

  <p class="userComment"><%= update.update_text %></p>
  </div>
<% end %>
Sign up to request clarification or add additional context in comments.

1 Comment

Ah! Figures it would be something so simple. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.