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

Avoid database check in rails template #565

Open
alec-c4 opened this issue Jun 29, 2021 · 0 comments
Open

Avoid database check in rails template #565

alec-c4 opened this issue Jun 29, 2021 · 0 comments

Comments

@alec-c4
Copy link

alec-c4 commented Jun 29, 2021

Hi!
I'd like to ask you - how to avoid database existence check when performing rails g rolify Role? I'd like to use rolify in my rails app template, but because DB isn't created yet everytime I run my generator I see an error

❯ rails g rolify Role
Running via Spring preloader in process 37095
      invoke  active_record
      create    app/models/role.rb
      insert    app/models/role.rb
/Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:81:in `rescue in new_client': FATAL:  database "test_app_development" does not exist (ActiveRecord::NoDatabaseError)
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:77:in `new_client'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activerecord-6.1.4/lib/active_record/connection_handling.rb:283:in `connection'
	from (erb):14:in `migration_template'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/3.0.0/erb.rb:905:in `eval'
	from /Users/alec/.rbenv/versions/3.0.1/lib/ruby/3.0.0/erb.rb:905:in `result'

BTW: you can check my template here

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

1 participant