I have a simple show method that has to render all the messages in a conversation.
Everything is basic in my code, I have a show method that goes to this HTML (show.html.haml):
%section#list
= @conversation.messages.each do |message|
.row
= message.content
= message.participant.user_id
And when I go to this show page, I have my content, but I also have a random line from the database (my HTML contains nothing else). Here is what I get :
This is a test 1
[#< MyghtDefaultMessenger::Message id: 1, content: "This is a test", deleted: false, participant_id: 1, created_at: "2017-02-13 14:52:45", updated_at: "2017-02-13 14:52:45" >]
(I added a blank space right next to the < and > signs else SO would just render, but they aren't here in the original. [#] )
Here is my controller method in conversation_controller :
def show
@conversation.messages.order(:created_at)
end
And the only specificity is that my conversation has many participants, my participants have many messages, and I get the messages of a conversation through participants.
=in= @conversation.messages.each do |message|. In ERB=is not used when you dont want to print the output of that particular ruby code, for example.eachblock.