activerecord-jsonb-associations icon indicating copy to clipboard operation
activerecord-jsonb-associations copied to clipboard

Uninitialized constant ActiveRecord::Associations::Preloader::HasMany (NameError)

Open richardvenneman opened this issue 7 years ago • 5 comments

When using this gem with Rails 5.2.1 (see #2) I encounter an error: uninitialized constant ActiveRecord::Associations::Preloader::HasMany (NameError).

Traceback (most recent call last):
	35: from bin/rails:6:in `<main>'
	34: from bin/rails:6:in `require'
	33: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<top (required)>'
	32: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/command.rb:46:in `invoke'
	31: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/command/base.rb:65:in `perform'
	30: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
	29: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
	28: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
	27: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/commands/test/test_command.rb:33:in `perform'
	26: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/test_unit/runner.rb:39:in `run'
	25: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/test_unit/runner.rb:50:in `load_tests'
	24: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/test_unit/runner.rb:50:in `each'
	23: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/test_unit/runner.rb:50:in `block in load_tests'
	22: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.1/lib/rails/test_unit/runner.rb:50:in `require'
	21: from /Users/richard/Projects/cityspotters/test/models/author_test.rb:3:in `<top (required)>'
	20: from /Users/richard/Projects/cityspotters/test/models/author_test.rb:3:in `require'
	19: from /Users/richard/Projects/cityspotters/test/test_helper.rb:4:in `<top (required)>'
	18: from /Users/richard/Projects/cityspotters/test/test_helper.rb:4:in `require'
	17: from /Users/richard/Projects/cityspotters/config/environment.rb:4:in `<top (required)>'
	16: from /Users/richard/Projects/cityspotters/config/environment.rb:4:in `require_relative'
	15: from /Users/richard/Projects/cityspotters/config/application.rb:9:in `<top (required)>'
	14: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler.rb:114:in `require'
	13: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:65:in `require'
	12: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:65:in `each'
	11: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:72:in `block in require'
	10: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:95:in `rescue in block in require'
	 9: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:95:in `require'
	 8: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/activerecord-jsonb-associations-fae5bfb0bf65/lib/activerecord/jsonb/associations.rb:26:in `<top (required)>'
	 7: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:42:in `on_load'
	 6: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:42:in `each'
	 5: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:43:in `block in on_load'
	 4: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
	 3: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
	 2: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
	 1: from /Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:71:in `instance_eval'
/Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/bundler/gems/activerecord-jsonb-associations-fae5bfb0bf65/lib/activerecord/jsonb/associations.rb:63:in `block in <top (required)>': uninitialized constant ActiveRecord::Associations::Preloader::HasMany (NameError)

/Users/richard/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/guard-2.14.2/lib/guard/jobs/pry_wrapper.rb:279: warning: method Pry#input_array is deprecated. Use Pry#input_ring instead
[1] guard(main)>

Please let me know if there's any information I can provide to help.

richardvenneman avatar Nov 09 '18 23:11 richardvenneman

@richardvenneman thank you for reporting. It seems preloading changed in rails 5.2.

I will try to fix this in next couple of weeks

y9v avatar Nov 12 '18 13:11 y9v

Any news?

top4ek avatar Apr 17 '19 06:04 top4ek

sorry, had no time to fix this issue. Seems that Rails 5.2.1 changed some internal stuff

y9v avatar Apr 17 '19 07:04 y9v

Tested this, and seems to be working fine on 5.2.2.1. At least belogns_to :)

top4ek avatar Apr 17 '19 07:04 top4ek

@y9v any chance of reviewing/possibly using the fix linked above?

swrobel avatar Aug 06 '19 00:08 swrobel