1
我在尝试调用控制器中的方法时遇到错误。关于如何使这个工作有效的教程,但只是有点卡在泥里,需要一些帮助。控制器中的未定义方法
NoMethodError in CatalogController#index
undefined method `art' for #<Class:0x007fbe8c338310>
我的模型
require 'httparty'
require 'json'
class Feed < ActiveRecord::Base
include HTTParty
base_uri 'https://www.parsehub.com/api/v2/runs'
# GET /feeds
# GET /feeds.json
def art
response = self.class.get("/tnZ4F47Do9a7QeDnI6_8EKea/data?&format=json")
@elements = response.parsed_response["image"]
@parsed = @elements.collect { |e| e['url'] }
end
end
我控制器
class CatalogController < ApplicationController
def index
@images = Feed.art
end
end
我猜测它的东西很简单,我忘了。