私のアプリには本当に奇妙なエラーメッセージが表示されています。私のコントローラでは私が持っている:Ruby on Rails Twitterの傾向 - TypeError =文字列を整数に変換できませんか?
require 'open-uri'
require 'json'
class NoticiasController < ApplicationController
def index
url = 'https://api.twitter.com/1/trends/daily.json'
buffer = open(url, "UserAgent" => "Ruby-Wget").read
# convert JSON data into a hash
@result = JSON.parse(buffer)
end
end
とビューで私は
<div>
<% for news in @result['trends'] %>
<p><%= news['name'] %></p>
<% end %>
</div>
を持っているが、私は「TypeError例外を:文字列を整数に変換できません」を取得します。
私は間違っていますか?
がどの行にエラーが出たのですか? – topek
<%= news ['name']%>
–@Joe Doyle:[クリーンアップ](http://meta.stackexchange.com/questions/128315/the-great-stack-overflow- tag-question-clean-of-2012)、これは[tag:trends]の正当な使用ではありませんか? –