我已经创建了控制器/关注一个问题叫做reports.rbClassMethods在控制器关注返回NoMethodError
在这里面,我创建了ClassMethods模块。它看起来像这样
module Reports
extend ActiveSupport::Concern
included do
require 'peddler'
require 'csv'
end
module ClassMethods
def report_details(token, marketplace_id, merchant_id)
#...
end
我包括这种担忧在我的招商控制器是这样的:
class MerchantsController < ApplicationController
include Reports
然后试着拨打report_details方法,像这样招控制器上的动作:
def pull_from_amazon
me = Merchant.find(params[:merchant_id])
marketplace = me.marketplace
token = me.token
Merchant.report_details(token, marketplace, params[:merchant_id])
redirect_to root_path
end
根据这个帖子Rich on Rails我应该能够调用:
Merchant.report_details(xx,xxx,xxxx)
但我得到一个NoMethodError当我尝试。我也试过:
me.report_details(xx,xxx,xxxx)
,并得到了相同NoMethodError
我做错了什么?
你重新启动Rails吗? –