Railsで取得したデータとそのハッシュが表示される

2012年1月23日 Posted by PURGE

ハマった件。なぜかrailsの viewにて、データとその下にハッシュ形式で重複表示されてしまう。
結論から言うと、タグの記述が間違っていた。

#間違い
<%= @timelines.each do |timeline| %>

#正式
<% @timelines.each do |timeline| %>
    #コンシューマキーとトークンを設定
    Twitter.configure do |config|
        config.consumer_key = consumer_key
        config.consumer_secret = consumer_secret
        config.oauth_token = token
        config.oauth_token_secret = token_secret
    end

    #タイムライン取得
    @timelines = Twitter.user_timeline(twitter_id)
<h2>TimeLines</h2>
<% @timelines.each do |timeline| %>
<div>
	<%= timeline.user.screen_name %>
	<%= timeline.text %>
</div>
<% end%>

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です