1

I have a controller that calls a model method:

class WelcomeController < ApplicationController
  item_num = params[:item_num] || "0001"
  @product = Scraper.lookup_item(item_num)
end

Here is the Scraper model:

class Scraper < ActiveRecord::Base
  require 'nokogiri'
  require 'mechanize'

  def self.lookup_item(item_num)
    # code goes here
  end
end

Why am I getting this error?

NoMethodError: undefined method 'lookup_item' for Scraper:Module

4

1 回答 1

1

我以前遇到过这个错误。grep您的项目以查看是否module Scraper在任何地方定义。如果是,请将其删除,或将其更改为类而不是模块。

于 2013-10-17T00:02:35.303 回答