Question: Rails prints the query result along with the object data in the view

Question

Rails prints the query result along with the object data in the view

Answers 1
Added at 2016-12-26 08:12
Tags
Question

I want to create a notebook app in rails. I need to print all the notes in the index view, so below is code in haml.

 = @notes.each do |note|
   %h1= link_to note.title, note
   %p= time_ago_in_words(note.created_at)

The problem is after the Note title and created time are displayed, the query result is printed at the end(Screenshot below).

enter image description here The issue persists only while printing all the notes at once using loop. Can't figure out what's the issue. Thanks in advance.

Answers
nr: #1 dodano: 2016-12-26 08:12

Change = with -

- @notes.each do |note|

If you just want to loop over @notes use - if you want to print some output use =

- @notes.each do |note|
   %h1= link_to note.title, note
   %p= time_ago_in_words(note.created_at)
Source Show
◀ Wstecz