Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
548 views
in Technique[技术] by (71.8m points)

ruby on rails - Why Generated Active Record Query dosen't run in sidekiq

I am having a code that runs a delayed job that generates a report and then sends in an email here : InstancesExportJob.perform_later(instances: instances, custom_field_key: options[:custom_field_key],tag_columns: options[:tags],user: User.current,report_url: report_url)

where instances is a generated active record query that is generated by another class this code fails and gives the following error: ActiveJob::SerializationError:Unsupported argument type: ActiveRecord::Relation. where the first operation that is done on instances is a map function call.

but changing the code to this makes it work fine: InstancesExportJob.perform_later(instances: instances.to_a, custom_field_key: options[:custom_field_key],tag_columns: options[:tags],user: User.current,report_url: report_url).

I am confused as running the code without delayed jobs works fine.

Am using rails 4.2 and sidekiq


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think the problem was with sidekiq as it do not allow a wide variety of parameter types and having the instance as an active record relation made the whole thing raise an error


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...