sidekiq_mailer icon indicating copy to clipboard operation
sidekiq_mailer copied to clipboard

NoMethodError (undefined method `key?' for #<JSON::Ext::Generator::State:0x007........

Open twiduch opened this issue 12 years ago • 5 comments

I am getting that error when trying with sidekiq_mailer 0.0.6

twiduch avatar Oct 03 '13 11:10 twiduch

@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

scottkf avatar Oct 29 '13 17:10 scottkf

+1 I'm getting the same error. This happened after upgrading from Rails 3.2 to 4.0.

chadwtaylor avatar Feb 16 '14 13:02 chadwtaylor

I pass to action mailer object id and there load object. It work!!! (not need to pass live object to mailer, only id)

keo64 avatar Jun 11 '14 13:06 keo64

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.

andersondias avatar Jun 11 '14 13:06 andersondias

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

scottkf avatar Jun 11 '14 13:06 scottkf