1
我有一个控制器调用模型方法:为什么我的模型被识别为模块?
class WelcomeController < ApplicationController
item_num = params[:item_num] || "0001"
@product = Scraper.lookup_item(item_num)
end
这里是Scraper
型号:
class Scraper < ActiveRecord::Base
require 'nokogiri'
require 'mechanize'
def self.lookup_item(item_num)
# code goes here
end
end
为什么会出现这个错误?
NoMethodError: undefined method 'lookup_item' for Scraper:Module
你的'''config/application.rb'''中是否有一行'''模块Scraper'''? 没有发布答案,因为我只有90%的把握。 – mechanicalfish