0

I have created a concern in controllers/concerns called reports.rb

In it I created the ClassMethods module.. It looks like this

module Reports
  extend ActiveSupport::Concern

included do
    require 'peddler'
    require 'csv'
end

module ClassMethods

    def report_details(token, marketplace_id, merchant_id)
      #...
    end

I included this concern in my Merchants controller like this:

class MerchantsController < ApplicationController
  include Reports

And then tried to call the report_details method in an action on the Merchants controller like so:

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

According to this post Rich on Rails I should be able to call:

Merchant.report_details(xx,xxx,xxxx)

But I get a NoMethodError when I try.. I also tried:

me.report_details(xx,xxx,xxxx)

And got the same NoMethodError

What did I do wrong?

4

1 回答 1

1

尝试这个

MerchantController.report_details(xx,xxx,xxxx)

但是你最好在模型中包含这个问题。

于 2015-09-03T14:33:04.363 回答