TypeError:无法克隆Symbol - Devise和Delayed_job - Mobile vs Desktop登录问题

时间:2015-04-17 18:33:31

标签: ruby-on-rails devise delayed-job

我的代码的最新版本存在问题,用户无法通过移动设备登录,但他们可以登录桌面。

我正在使用devise(v3.4.1)作为我的活动记录管理器,并且当delayed_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'

问题通过设计中的'create'方法发生:

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

有没有人对如何进一步调试或了解手机与桌面上传递的参数差异有任何建议?

THX!

1 个答案:

答案 0 :(得分:1)

经过两天艰苦的调试后,事实证明我试图异步处理用户属性,并且用户活动记录模型由于完成了延迟作业而没有完全完成。