ruby on rails - Date object turns into String when using Sidekiq -


i have problem when pass date objects arguments different methods, turn string.

in rails app, there service calls sidekiq worker execute method in model.

when service object initialized, has date instance methods. have confirmed types using debugger.

it passes instance methods sidekiq worker using perform_async. perform method sidekiq 1 line method invokes method in model, passing arguments received service model.

in model side, argument passed in sidekiq worker no longer date type. string (e.g. "2015-01-20"). have confirmed using degugger.

any thoughts on why happening?

when call perform_async method on sidekiq worker, provided arguments translated json can stored in redis queue sidekiq background workers pull from, , translated primitive types json passed perform in background worker process. because of this, it's best pass simple arguments sidekiq workers; in fact, it's best practice.

for specific problem, take date passed perform method of worker , use date.parse(date_string) turn date object. in case, might want call to_s on argument perform_async, make obvious later readers of code passed perform string.


Popular posts from this blog