Odd output with Rails every loop

I have an idea that for some reason the memory cell of the object I'm trying to execute is displayed. I am new to rails, so I do not know why this is happening. An object is a note with two fields, a title and content.

In the controller I have (in the index function)

@note = Note.all

Then in the view I do it

<%= @notes.each do |note| %>
    <%= link_to note.title, "notes/#{note.id}"%>
<% end %>

Browser output School Work #Note:0x1042e4708>#Note:0x1042e2ae8>

thanks for the help

+3
source share
1 answer

but not:

<%= @notes.each do |note| %>

using:

<% @notes.each do |note| %>

wrapping ruby ​​in <%=%>always outputs something to the view, discards the equal sign ( <%%>) to just execute ruby ​​without output

+7
source

Source: https://habr.com/ru/post/1782027/


All Articles