Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Error: 'No connection pool for ActiveRecord::Base' when generating the devise_token_auth generator inside an Rails Engine #584

Closed
abhilashak opened this issue Mar 24, 2016 · 5 comments

Comments

@abhilashak
Copy link

abhilashak commented Mar 24, 2016

I have an Rails Engine in my app (authentication_manager). I tried to implement this gem inside my engine. So I added this gem inside the engines Gemfile and installed it.

But I am getting the following error:
No connection pool for ActiveRecord::Base (ActiveRecord::ConnectionNotEstablished)

I am using postgresql and all configuration is correct. And I tried devise and generated it inside this engine and not found any issue.

vagrant@vagrant-ubuntu-trusty-64:~/my-app/components/authentication_manager$ rails g devise_token_auth:install User auth
create config/initializers/devise_token_auth.rb
create db/migrate/20160324104352_devise_token_auth_create_user.rb
/home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:570:in retrieve_connection': No connection pool for ActiveRecord::Base (ActiveRecord::ConnectionNotEstablished) from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:113:inretrieve_connection'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:87:in connection' from /home/vagrant/.rbenv/versions/2.2.1/gemsets/my-app-authentication-manager/gems/devise_token_auth-0.1.37/lib/generators/devise_token_auth/install_generator.rb:151:indatabase_name'
from **/home/vagrant/.rbenv/versions/2.2.1/gemsets/my-app-authentication-manager/gems/devise_token_auth-0.1.37/lib/generators/devise_token_auth/install_generator.rb:135:in postgres?'** from /home/vagrant/.rbenv/versions/2.2.1/gemsets/my-app-authentication-manager/gems/devise_token_auth-0.1.37/lib/generators/devise_token_auth/install_generator.rb:131:in json_supported_database?'
from (erb):43:inmigration_template' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/2.2.0/erb.rb:863:in eval'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/2.2.0/erb.rb:863:inresult' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/generators/migration.rb:64:in block in migration_template'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:incall' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in render'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:inblock (2 levels) in invoke!' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in open'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:inblock in invoke!' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in call'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:ininvoke_with_conflict_check' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions/create_file.rb:60:in invoke!'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/actions.rb:94:inaction' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/generators/migration.rb:34:in create_migration'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/generators/migration.rb:63:inmigration_template' from /home/vagrant/.rbenv/versions/2.2.1/gemsets/my-app-authentication-manager/gems/devise_token_auth-0.1.37/lib/generators/devise_token_auth/install_generator.rb:18:in copy_migrations'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:inrun' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in invoke_command'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:inblock in invoke_all' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in each'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:inmap' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in invoke_all'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/group.rb:232:indispatch' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in start'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/generators.rb:157:ininvoke' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/commands/generate.rb:13:in <top (required)>'
from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/engine/commands.rb:19:inrequire' from /home/vagrant/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.6/lib/rails/engine/commands.rb:19:in <top (required)>'
from bin/rails:12:inrequire' from bin/rails:12:in

'

@kolyastepanets
Copy link

+1

1 similar comment
@kopchak
Copy link

kopchak commented Jun 3, 2016

+1

@kolyastepanets
Copy link

If it helps anyone, you can resolve it by manual creating migration file, add routes, add all stuff that generator do.

@abhilashak
Copy link
Author

abhilashak commented Jun 6, 2016

This bug comes from the devise_token_auth gem where the gem checks the database is Postgres or not in 'postgres?' method.
/home/vagrant/.rbenv/versions/2.2.1/gemsets/my-app-authentication-manager/gems/devise_token_auth-0.1.37/lib/generators/devise_token_auth/install_generator.rb

So I just done a monkey patching inside the method and returned true (just say 'yes' to postgres? method, because I am using postgres). And run the generator again.

Hope this will be soon solved by the authors of 'devise_token_auth' gem.

@abhilashak abhilashak changed the title Getting Error when generating the devise_token_auth generator inside an Engine Getting Error No connection pool for ActiveRecord::Base when generating the devise_token_auth generator inside an Engine Jun 13, 2016
@abhilashak abhilashak changed the title Getting Error No connection pool for ActiveRecord::Base when generating the devise_token_auth generator inside an Engine Getting Error: 'No connection pool for ActiveRecord::Base' when generating the devise_token_auth generator inside an Engine Jun 13, 2016
@abhilashak abhilashak changed the title Getting Error: 'No connection pool for ActiveRecord::Base' when generating the devise_token_auth generator inside an Engine Getting Error: 'No connection pool for ActiveRecord::Base' when generating the devise_token_auth generator inside an Rails Engine Jun 13, 2016
@zachfeldman
Copy link
Contributor

Sounds like we have a proposed solution here, so closing for now.

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

No branches or pull requests

4 participants