ruby-on-rails – 作业无法加载:“@”不允许作为实例变量名称
发布时间:2020-12-17 02:06:12 所属栏目:百科 来源:网络整理
导读:我在使用延迟工作时一直遇到错误. Job failed to load: `@' is not allowed as an instance variable name. 在这里打电话: report = Report.find(params[:id])report.delay.record_fixing( report.records.where(found: nil,pending: nil) )redirect_to rep
我在使用延迟工作时一直遇到错误.
Job failed to load: `@' is not allowed as an instance variable name. 在这里打电话: report = Report.find(params[:id]) report.delay.record_fixing( report.records.where(found: nil,pending: nil) ) redirect_to reports_path 记录修复是 def record_fixing(records) records.search_fullcontact end 解决方法
这里出现此问题的原因是传递给方法record_fixing的参数,即
ActiveRelation Object(report.records.where(found: nil,pending: nil)) 与方法名称一起序列化,因为延迟作业由于某种原因这样做,并且它没有这样做,因此引发了这个错误,并将它添加到表列last_error,所以为了解决这类问题,我建议,我们应该传递对象id而不是整个对象,并在方法record_fixing中获取该对象,其目的是提供更简单的参数用于序列化. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |