Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Sidekiq : Throwing Error Message #82

Open
puneetgaurr opened this issue Jan 21, 2018 · 0 comments
Open

Sidekiq : Throwing Error Message #82

puneetgaurr opened this issue Jan 21, 2018 · 0 comments

Comments

@puneetgaurr
Copy link

puneetgaurr commented Jan 21, 2018

I am using Sidekiq for the background process and creat a very simple application to validate Sidekiq functionality. I am getting success response but getting failure message when calling it through sidekiq. Please help me resolve this issue.

Error Message :
2018-01-21T15:40:57.662Z 73625 TID-outayy7ac WARN: {"context":"Job raised exception","job":{"class":"ProcessWorker","args":["{"name"=>"Hello", "description"=>"Hello666", "author"=>"Hello"}"],"retry":true,"queue":"default","jid":"866561849a5cd5336ef03cc4","created_at":1516548964.76175,"enqueued_at":1516549257.6588979,"error_message":"When assigning attributes, you must pass a hash as an argument.","error_class":"ArgumentError","failed_at":1516548964.76448,"retry_count":3,"retried_at":1516549132.7047172},"jobstr":"{"class":"ProcessWorker","args":["{\"name\"=>\"Sumit8901\", \"description\"=>\"Hello666\", \"author\"=>\"Hello7777\"}"],"retry":true,"queue":"default","jid":"866561849a5cd5336ef03cc4","created_at":1516548964.76175,"enqueued_at":1516549257.6588979,"error_message":"When assigning attributes, you must pass a hash as an argument.","error_class":"ArgumentError","failed_at":1516548964.76448,"retry_count":3,"retried_at":1516549132.7047172}"}
2018-01-21T15:40:57.662Z 73625 TID-outayy7ac WARN: ArgumentError: When assigning attributes, you must pass a hash as an argument.
2018-01-21T15:40:57.662Z 73625 TID-outayy7ac WARN:

Please find the below code-

Controller class:
books_controller.rb
def create
@job=ProcessWorker.perform_async(book_params)
h = {"response" => {"job_id" => @job}}
render json: h
end

Worker Class:

class ProcessWorker
include Sidekiq::Worker
def perform(book_params)
book = Book.new(book_params)
book.save
end
end

Migrations Class:
class CreateBooks < ActiveRecord::Migration[5.1]
def change
create_table :books do |t|
t.string :name
t.string :description
t.string :author

  t.timestamps
end

end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant