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

Ensure loading works without ActiveRecord #69

Merged
merged 1 commit into from
Dec 12, 2017

Conversation

artfuldodger
Copy link
Contributor

Fixes uninitialized constant ActiveRecord::Base::ConnectionHandling (NameError) exception

Full stack trace:

/Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activerecord-5.1.4/lib/active_record/base.rb:281:in `<class:Base>': uninitialized constant ActiveRecord::Base::ConnectionHandling (NameError)
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activerecord-5.1.4/lib/active_record/base.rb:275:in `<module:ActiveRecord>'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activerecord-5.1.4/lib/active_record/base.rb:25:in `<top (required)>'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/rails-observers-0.1.5/lib/rails/observers/railtie.rb:37:in `block in <class:Railtie>'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:67:in `block in execute_hook'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `each'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/application/finisher.rb:73:in `block in <module:Finisher>'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `instance_exec'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `run'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/initializable.rb:59:in `block in run_initializers'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `call'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/initializable.rb:58:in `run_initializers'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/application.rb:353:in `initialize!'
	from /Users/bonusly/bonusly/special_sauce/config/environment.rb:5:in `<top (required)>'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/application.rb:329:in `require_environment!'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/command/actions.rb:16:in `require_application_and_environment!'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands/generate/generate_command.rb:19:in `perform'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
	from /Users/bonusly/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
	from bin/rails:4:in `require'
	from bin/rails:4:in `<main>'

@@ -35,7 +35,7 @@ class Railtie < ::Rails::Railtie
# which eventually calls `observed_class` thus constantizing `"User"`,
# the class we're loading. 💣💥
require "active_record/base"
rescue LoadError
rescue LoadError, NameError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of doing this we should be requiring active_record before active_record/base. Can you change it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafaelfranca Yup, makes sense. Updated!

Fixes `uninitialized constant ActiveRecord::Base::ConnectionHandling (NameError)` exception
@rafaelfranca rafaelfranca merged commit c8712f5 into rails:master Dec 12, 2017
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

Successfully merging this pull request may close these issues.

2 participants