0

I'm just making a newsfeed that is database driven, right now I have it working, but at the end of every news post, I get a string like so:

 21   <div id='newsfeed'>
 22     <%= @news.each do |new| %>
 23       <div class='span10'>
 24         <h3><%= new.title %></h3>
 25         <p class='muted'><%= new.date %></p>
 26         <p><%= new.body %></p>
 27       </div>
 28     <% end %>
 29   </div>
 30 </div>

and then my controller has this:

def home
    @news = Newsfeed.all
end

Yet the output looks like this:

enter image description here

It would work great if it didn't post the entire array, I'm not sure why it would.. Thanks!

2 Answers 2

0

You should use "silent"

<% @news.each do |new| %>

instead of

<%= @news.each do |new| %>
Sign up to request clarification or add additional context in comments.

Comments

0

Remove the equals sign on line 22:

 21   <div id='newsfeed'>
 22     <% @news.each do |new| %>
 23       <div class='span10'>
 24         <h3><%= new.title %></h3>
 25         <p class='muted'><%= new.date %></p>
 26         <p><%= new.body %></p>
 27       </div>
 28     <% end %>
 29   </div>
 30 </div>

Comments

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.