0

I am pulling a livestream of data and trying to format it as a table. I saw this post but I am having an odd issue. The table formatting ["</td>\n\t\t</tr>\n", "</td>\n\t\t</tr>\n",....... shows up at the top of the page, above the table itself (which is correctly formatted). Can someone explain why this is?

<h1>Controller1#index</h1>

graphic started<br>

<%= line_chart( [1,2,3,4,5] ) %>

<br>graphic done

<%
term="google"

client = Twitter::REST::Client.new do |config|
  config.consumer_key        = "bi5rmrxr"
  config.consumer_secret     = "GVflzHe72OZp"
  config.access_token        = "263-SYURzb"
  config.access_token_secret = "Spc9"
end
%>
<table class="table table-condensed">
    <thead>
        <td>screen name</td> <td>time created</td><td>times favorited</td><td>text</td>
    </thead>
<%= client.search("#{term} -rt", lang: "en").take(100).collect do |tweet| %>
        <tr>
        <td><%= "#{tweet.user.screen_name}"%></td>
        <td><%= "#{tweet.created_at}"%></td>
        <td><%= "#{tweet.favorite_count}"%></td>
        <td><%= "#{tweet.text}"%></td>
        </tr>
    <% end %>
</table>

1 Answer 1

1

you are printing client complete search as well which is being displayed at the top. you should not do not do. replace this

 <%= client.search("#{term} -rt", lang: "en").take(100).collect do |tweet| %>

with this

<% client.search("#{term} -rt", lang: "en").take(100).collect do |tweet| %>
Sign up to request clarification or add additional context in comments.

2 Comments

So you are saying that <%= xxxx %> evaluates the expression and returns the all of the contents (including html) while <% xxx %> only prints the xxx to the screen?
When you use <%= it will display whatever is inside. <% is used for traversing things or the logic you are using which you don't want to print in views.

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.