mhfs/devise-async

`const_get': uninitialized constant Devise::Models::Async (NameError)

Closed this issue · 13 comments

Having a strange error when trying to use your devise-async gem. The only thing special I am including is invitable. Here's a stack trace for you:

from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/models.rb:97:in `block (2 levels) in devise'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/models.rb:92:in `each'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/models.rb:92:in `block in devise'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/models.rb:123:in `devise_modules_hook!'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/models.rb:90:in `devise'
    from /Users/allenwyma/Documents/Aptana Studio 3 Workspace/plangora/app/models/user.rb:6:in `<class:User>'
    from /Users/allenwyma/Documents/Aptana Studio 3 Workspace/plangora/app/models/user.rb:1:in `<top (required)>'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:230:in `block in constantize'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `each'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/inflector/methods.rb:229:in `constantize'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise.rb:261:in `get'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/mapping.rb:77:in `to'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/mapping.rb:72:in `modules'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/mapping.rb:89:in `routes'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/mapping.rb:156:in `default_used_route'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/mapping.rb:66:in `initialize'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise.rb:295:in `new'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise.rb:295:in `add_mapping'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/rails/routes.rb:208:in `block in devise_for'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/rails/routes.rb:207:in `each'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/bundler/gems/devise-d5a2a9b2da15/lib/devise/rails/routes.rb:207:in `devise_for'
    from /Users/allenwyma/Documents/Aptana Studio 3 Workspace/plangora/config/routes.rb:3:in `block in <top (required)>'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:282:in `eval_block'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:260:in `draw'
    from /Users/allenwyma/Documents/Aptana Studio 3 Workspace/plangora/config/routes.rb:1:in `<top (required)>'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:40:in `each'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:40:in `load_paths'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:16:in `reload!'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:26:in `block in updater'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/file_update_checker.rb:78:in `call'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.8/lib/active_support/file_update_checker.rb:78:in `execute'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:27:in `updater'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/allenwyma/Documents/Aptana Studio 3 Workspace/plangora/config/environment.rb:5:in `<top (required)>'
    from /Users/allenwyma/Documents/Aptana Studio 3 Workspace/plangora/config.ru:4:in `block in <main>'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
    from /Users/allenwyma/Documents/Aptana Studio 3 Workspace/plangora/config.ru:1:in `new'
    from /Users/allenwyma/Documents/Aptana Studio 3 Workspace/plangora/config.ru:1:in `<main>'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands/server.rb:46:in `app'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands/server.rb:70:in `start'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
    from /Users/allenwyma/.rvm/gems/ruby-1.9.3-p286/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Not quite sure what is going on, but I did have the initializer put in. Any thoughts? Also does this cover invitable gem?

mhfs commented

Hey @HangingClowns, would you mind sharing the rails, devise and devise-async versions? Also how are you installing devise-async in your model?

Regarding devise-invitable, I never used it so I can't say if it plays well with devise-async.

Thanks!

Actually, I just tried installing from the github repo, now, instead of the gem file and it works! Sorry about that. Talked prematurely!

mhfs commented

No problem - I guess what caused your issue was the README being out of sync with the current released gem. Sorry about that. I just released 0.4.0. Please let me know if you have any other issues.

BTW, last time I used bundler to install from rubygems, then I tried to use your's from github, and the one from github worked.

I'm getting this as well, and installing directly from the repo fixes it. I'd like to be able to depend on a version rather then a live repo though.

mhfs commented

@Rodeoclash did you try with 0.4.0?

Same issue for me

NameError: uninitialized constant Devise::Async::Proxy

How can one fix this in a solid way?

I recently upgraded all my gems and I'm getting this error again. Switched the gem to pull directly from the repo with the same issue.

Very strange, digging into it.

Ok, fixed it. Just remove the line:

config.mailer = "Devise::Async::Proxy"

From the Devise config (as specified here: https://github.com/plataformatec/devise/wiki/How-To:-Send-devise-emails-in-background-(Resque,-Sidekiq-and-Delayed::Job) )

Really, it's all about reading the instructions isn't it ;)

mhfs commented

Glad to here. Sorry about the API changes in the last couple of releases. I'm trying to find the ideal approach before 1.0. Seems to have reached that point now.

This is still happening occasionally with 0.9, Rails 3.2, and Ruby 2.1.2

Still getting this error about 50% of the time when i do rake db:migrate or rails c commands.
const_get': uninitialized constant Devise::Models::Async (NameError)
I'm running Rails 4.2.5.2 and Ruby 2.2.2p95. Devise 4.1.1 & Devise-async 0.7.0. Sometimes it goes away and then comes back again. repeating the command again a few times often works, but that's no fun.

Quick update: I fixed this by updating devise-async to version 0.10.1 and are now using with older version of devise 3.5.10, ran bundle, restarted rails server, and so far it appears to have solved this issue.