sidekiq_mailer
sidekiq_mailer copied to clipboard
NoMethodError (undefined method `key?' for #<JSON::Ext::Generator::State:0x007........
I am getting that error when trying with sidekiq_mailer 0.0.6
@twiduch This is a probably when using this with devise, because devise passes in the User or whichever model and not a user's attributes, don't know the fix yet
+1 I'm getting the same error. This happened after upgrading from Rails 3.2 to 4.0.
I pass to action mailer object id and there load object. It work!!! (not need to pass live object to mailer, only id)
In order to use sidekiq_mailer you need to pass simple objects as parameters to actions. Instead of receiving complex Objects, such as User, you should pass user id, or any integer, string, boolean objects.
In my case it was devise causing the problem, and a quick fix can be the following - you could also change devise as well
Sidekiq::Mailer.excluded_environments = [:test, :cucumber]
# monkey patch so sidekiq mailer doesn't handle devises backgrounding
# which would try to serialize the user object
class Sidekiq::Mailer::Proxy
def deliver
return deliver! if Sidekiq::Mailer.excludes_current_environment? || @mailer_class.to_s == "Devise::Mailer"
Sidekiq::Mailer::Worker.client_push(to_sidekiq)
end
end