Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7713623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:55:07+00:00 2026-06-01T01:55:07+00:00

I recently started learning RoR. My problem is I get an unintended output when

  • 0

I recently started learning RoR. My problem is I get an unintended output when I call the post in the html.erb file.

1 class TestSiteController < ApplicationController 
2   def Home 
3     @greeting = 'Hello' 
4     @posts = Post.all 
5
6     respond_to do |format|
7       format.html 
8       format.xml  { render :xml => @posts }
9       format.json { render :json => @posts }
10     end
11   end    


1 <h1>testsite#home</h1>
2 <%= link_to "contact", about_us_path %>
3 
4 <table>
5 <%= @posts.each do |p| %> 
6 <tr>
7   <td><%= p.topic %></td>
8   <td><%= p.post %> </td> 
9 </tr>
10 <% end %>
11 </table>

I get the list of posts I want below, but on top of the list is an array of posts I do not want outputted. Anyone know why this is happening?

Below is the output:

//Unwanted array
[#<Post id: 1, topic: "Rainy Day", post: "Today was a rainy day", created_at: "2012-03-29    21:22:43", updated_at: "2012-03-29 21:22:43">, #<Post id: 2, topic: "It works!", post: "Saving   data from the rails console to the mysql db ...", created_at: "2012-03-29 21:25:18", updated_at: "2012-03-29 21:25:18">]
//List start
Rainy Day   Today was a rainy day
It works!   Saving data from the rails console to the mysql db work! I'm so ecstatic! :D
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:55:09+00:00Added an answer on June 1, 2026 at 1:55 am

    You’re outputting the contents of @posts because you’re using <%=. You should change it to <%:

    <% @posts.each do |p| %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just recently started learning RoR and found that Prototype.js is a default javascript
I've recently started learning SWT (on class #4, to be precise) due to business
I've just recently started learning HTML/CSS and I've been trying to teach myself sound
I've recently started learning html, css and Javascript and I'm understanding more and more
I recently started learning Emacs . I went through the tutorial, read some introductory
I recently started learning Python and I was rather surprised to find a 1000
I recently started learning JavaFX. At the moment I can't build any JavaFX project
I have recently started learning F#, and this is the first time I've ever
I have recently started learning Perl and one of my latest assignments involves searching
I've been a web developer for some time now, and have recently started learning

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.