【问题标题】:Ruby on Rails jobs NotImplementedErrorRuby on Rails 作业 NotImplementedError
【发布时间】:2016-03-14 17:43:40
【问题描述】:

我正在尝试在我的 Ruby on Rails 应用程序中实现作业,但我不断收到此错误:

NotImplementedError

来自服务器的错误:

NotImplementedError (NotImplementedError):
  app/controllers/cron_controller.rb:6:in `message_10_minutes'

这是 ActiveJob:

class TestSmsJob < ActiveJob::Base
  queue_as :default

  #include Plivio

  def perform(*args)
    # do my stuff
  end
end

这是对执行作业的函数的调用:

class CronController < ApplicationController
  def index
  end

  def message_10_minutes
    TestSmsJob.set(wait: 10.minutes).perform_later()
    render :layout => false
  end
end

你们知道我错过了什么吗?

【问题讨论】:

标签: ruby-on-rails jobs


【解决方案1】:

Rails 默认带有自己的异步队列实现,但是您仍然需要指定要使用的适配器。如果您想使用内置适配器,您根本不必捆绑任何其他 gem。

这是适配器列表 - http://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html

由于sidekiq 对开始来说可能太难了,您可以使用sucker_punch - https://github.com/brandonhilkert/sucker_punch

选择适配器后,您必须更新配置

module YourApp
  class Application < Rails::Application
    # Be sure to have the adapter's gem in your Gemfile
    # and follow the adapter's specific installation
    # and deployment instructions.
    config.active_job.queue_adapter = :adapter_name
  end
end

【讨论】:

    猜你喜欢
    • 2013-06-14
    • 1970-01-01
    • 1970-01-01
    • 2013-05-01
    • 1970-01-01
    • 2013-03-05
    • 2017-11-09
    • 2017-04-14
    • 1970-01-01
    相关资源
    最近更新 更多