0

所以在我的 ArticlesController 中我设置了这个......

@most_recent_tweets = Twitter.home_timeline(count:1)

并在文章 index.html.erb 文件中...

    <% @most_recent_tweets.each do |tweet| %>
        <%= tweet["attrs"] %>
    <% end %>

这工作正常......我得到以下输出......

{:created_at=>"Mon Nov 26 04:45:31 +0000 2012", :id=>272924019395813376, :id_str=>"272924019395813376", :text=>"Episode 394: STI and Polymorphic Associations (pro) http://t.co/UrLLdY1n", :source=>".....etc}

所以这是我的问题..我如何只显示 :text 的值?

我希望我的输出是....

Episode 394: STI and Polymorphic Associations (pro) http://t.co/UrLLdY1n

我该怎么做呢?(感谢您的时间)

4

1 回答 1

0

明白了...鸣叫[“文本”]

所以....

<% @most_recent_tweets.each do |tweet| %>
    <%= tweet["attrs"] %>
<% end %>

变成……

<% @most_recent_tweets.each do |tweet| %>
    <%= tweet["text"] %>
<% end %>
于 2012-11-27T17:58:54.157 回答