我正在尝试从控制器方法运行 ActiveJob 作业,但它失败了,我无法找到问题的正确位置:
#app/controllers/users_controller.rb
1 class UsersController < ApplicationController
2 def new
3 @user = User.new
4 end1
5
6 def create
7 @user = User.create(user_params)
8 PoliciesChecksJob.new(@user.id).enqueue
9 # redirect to somewhere
10 end1
11 end
#app/jobs/policies_checks_job.rb
class PoliciesChecksJob < ActiveJob::Base
queue_as :default
def perform(user_id)
SearchPoliciesCommands.new.execute(user_id)
end
end
日志摘要:
Started POST "/users" for ::1 at 2015-03-30 15:01:03 +0100
Processing by UsersController#create as HTML
...(params)
(0.1ms) BEGIN
... (inserts the user)
(0.3ms) COMMIT
[ActiveJob] Enqueued PoliciesChecksJob (Job ID: da...e2) to Sneakers(default) with arguments: 1
Completed 500 Internal Server Error in 76ms
NoMethodError (private method `warn' called for nil:NilClass):
app/controllers/users_controller.rb:8:in `create'
我会很感激任何想法。