我正在尝试将一个模块包含在我的resque工作者中,但我一直收到此错误 -
failed: #<NoMethodError: undefined method `build_page' for RefreshEventCache:Class>
工人 - /app/worker/refresh_event_cache.rb
require File.dirname(__FILE__) + '/../../lib/locomotive/render.rb'
class RefreshEventCache
include Resque::Plugins::UniqueJob
include Locomotive::Render
@queue = :events_queue
def self.perform(url)
build_page(url)
end
end
模块 - /lib/locomotive/render.rb
module Locomotive
module Render
extend ActiveSupport::Concern
module InstanceMethods
def build_page(full_path)
Rails.logger.debug "BUILDING PAGE"
end
end
end
end
有什么想法吗?
答案 0 :(得分:2)
您是否尝试将扩展ActiveSupport :: Concern添加到主模块机车中,如下所示:
module Locomotive
extend ActiveSupport::Concern
module Render
module InstanceMethods
def build_page(full_path)
Rails.logger.debug "BUILDING PAGE"
end
end
end
end
猜测,...我已经使用了单个模块的扩展,但这对我来说似乎是合乎逻辑的。