1
我收到的時候我想,包括我的控制器內的寶石一個奇怪的錯誤,下面是我使用的控制器代碼和我得到的錯誤是:包括寶石不工作
> undefined method `include' for <CatalogController:0x00000002427b90>
返回該錯誤的代碼如下:
require 'httparty'
require 'json'
class CatalogController < ApplicationController
# GET /feeds
# GET /feeds.json
def index
# GRAB THE URL
include HTTParty
base_uri 'https://www.parsehub.com/api/v2/runs'
# PARSE THE RESPONSE
def art
response = self.class.get("/tnZ4F47Do9a7QeDnI6_8EKea/data?&format=json")
@elements = response.parsed_response["image"]
@parsed = @elements.collect { |e| e['url'] }
end
end
end
也不太清楚爲什麼這個錯誤返回?
將'include HTTParty'移出'index' – Aetherus
爲什麼你要在另一個裏面定義一個方法? – Aetherus
道歉仍然學習鐵軌! :) – Jonathan