[英]TypeError: can't clone Symbol - Devise and Delay_job - Mobile vs Desktop SignIn Issue
我的最新版本的代码存在问题,用户无法通过移动设备登录,但可以登录自己的桌面。
我将devise(v3.4.1)用作我的活动记录管理器,并且当devise登录后delay_job(v4.0.6)和delay_job_active_record(v4.0.3)尝试发送消息时发生错误。 请参阅stacktrace:
…/gems/delayed_job-4.0.6/lib/delayed/message_sending.rb: 37:in `clone'
…/gems/delayed_job-4.0.6/lib/delayed/message_sending.rb: 37:in `block in handle_asynchronously'
…2.0.0/gems/devise-3.4.1/lib/devise/models/trackable.rb: 33:in `update_tracked_fields!'
…/2.0.0/gems/devise-3.4.1/lib/devise/hooks/trackable.rb: 7:in `block in <top (required)>'
…undle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/hooks.rb: 14:in `call'
…undle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/hooks.rb: 14:in `block in _run_callbacks'
…undle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/hooks.rb: 9:in `each'
…undle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/hooks.rb: 9:in `_run_callbacks'
…dle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb: 53:in `_run_callbacks'
…undle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/proxy.rb: 179:in `set_user'
该问题通过设计中的“创建”方法发生:
def create
self.resource = warden.authenticate!(auth_options)
set_flash_message(:notice, :signed_in) if is_flashing_format?
sign_in(resource_name, resource)
yield resource if block_given?
respond_with resource, location: after_sign_in_path_for(resource)
end
当我“放入auth_options”时,无论是台式机还是移动机,我都会得到以下信息,因此我将继续进行进一步的调试。
14:12:57 web.1 | auth_options =
14:12:57 web.1 | {:scope=>:user, :recall=>"devise/sessions#new"}
引发错误的延迟作业message_sending.rb方法。 第37行是'curr_opts = opts.clone':
module ClassMethods
def handle_asynchronously(method, opts = {})
aliased_method, punctuation = method.to_s.sub(/([?!=])$/, ''), $1 # rubocop:disable PerlBackrefs
with_method, without_method = "#{aliased_method}_with_delay#{punctuation}", "#{aliased_method}_without_delay#{punctuation}"
define_method(with_method) do |*args|
curr_opts = opts.clone
curr_opts.each_key do |key|
next unless (val = curr_opts[key]).is_a?(Proc)
curr_opts[key] = if val.arity == 1
val.call(self)
else
val.call
end
end
delay(curr_opts).__send__(without_method, *args)
end
alias_method_chain method, :delay
end
是否有人对如何进一步调试或了解在移动设备与台式机上传递的参数差异有任何建议?
谢谢!
经过两天的调试,结果证明我试图异步处理用户属性,并且用户活动记录模型尚未完全完成,因为它是通过延迟作业来完成的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.