0
내가 접근 할 필요가 어디 레일 응용 프로그램을 구축하기 위해 노력하고있어 접속하기 Zomato APIAPI를
사람이 컨트롤러와 뷰를 생성하는 방법에 나를 인도 없습니다. 이 URL에서 식당의 이름을 얻고 싶다고 가정하면 : Restaurant 컨트롤러와 뷰를 작성하려면 어떻게해야합니까? 현재 저는 HTTParty gem을 사용하고 있습니다.
이
내 컨트롤러 코드 :def restaurants
@response = HTTParty.get("https://api.zomato.com/v1/restaurant.json/773", :headers => {"X-Zomato-API-Key" => "MYAPIKEY"})
puts response.body, response.code, response.message, response.headers.inspect
@categories = Category.where(:category_name => 'Restaurants')
end
내가보기에 응답 개체를 얻으려고 :
undefined method 'id' for ["id", 773]:Array
: 그래서
<%= @response.each do |item| %>
<td><%= item.id %></td>
<td><%= item.name %></td>
<td><%= item.url %></td>
<% end %>
을,이 다음과 같은 오류를 보여줍니다
[무엇을 시도해 봤습니까?] (http://whathaveyoutried.com/) – sczizzo
[스택 오버플로는 개인 연구 비서가 아닙니다.] (http://meta.stackexchange.com/a/128553/133242) –