-
Notifications
You must be signed in to change notification settings - Fork 40
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
Undefined method with for Model #50
Comments
Which Rail's version are you running? |
rails (6.0.3.4) |
Are you using classic or Zeitwerk autoloader? |
I am not sure about. It's not present in the Gemfile, but i found this in Gemfile.lock. I've tried to delete Gemfile.lock and re "bundle install" but it's still being added to Gemfile.lock.
I have searched for the word "Zeitwerk" across all files and it's present only in Gemfile.lock. No other references. |
If you never went into your couple of temp fixes you can try until I can address zeitwerk: in your otherwise you can add |
I have tried both options but I got the same error. I have tried to comment all inside "Application" class but it's the same. I think it's something related to the .with method. This works -> Item.where.any(field: 'text') NoMethodError (undefined method |
Try replacing the gem with I haven't done a new release quite yet. And the current Master branch includes a lot of Rails 6.0 fixes. Edit: I wanna redact my zeitwerk auto loader issue. I just spun up a new Rails 6 project and saw no issue in regard to it. |
Tried. Same error. |
It's hard to say tbh... I just created a new Rails 6.0.x project. And all I did was add the gem to the gemfile and its working for me, out of the box. source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.2'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.4'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
# gem 'image_processing', '~> 1.2'
gem "active_record_extended", git: "https://github.com/GeorgeKaraszi/ActiveRecordExtended.git"
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
# gem 'rack-cors'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'listen', '~> 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
ok, It seems the issue it's caused by |
hmmm, I'm glad your problem is solved. But it brings up another question as to why that gem would affect this one 🤔. |
I'm getting the same error as well, don't have resque installed (we use sidedkiq). |
@GeorgeKaraszi could it be due to how active record extended is being mixed into active record? What if it used the |
I also do not see it in the |
Any updates on this?
|
I've found a workaround for now: config/application.rb
thanks for the amazing gem! |
Great! This works for me too. |
The gem includes itself: ActiveRecord::Relation.prepend(ActiveRecordExtended::QueryMethods::Unionize) To my best knowledge, this is prone to load order errors. To be a good citizen, Railtie mechanism would better be used, e.g: ActiveSupport.on_load :active_record do
ActiveRecord::Relation.prepend ActiveRecordExtended::QueryMethods::Unionize
end Another lead that might reveal the mystery is one of the comments above: Item.where.any(field: 'text') # works
Profile.with(test: Profile.all) # doesn't work Is it class C < ActiveRecord::Base
end
C.ancestors.include?(ActiveRecord::Relation)
=> false 🤔 |
Bump |
Made some significant changes to the gem's loading ability. I would suggest pulling the latest branch down to test if the recent changes has solved some of these lingering problems. I suspect this is a chicken or egg problem with what is getting loaded first. |
I've tested the master branch, and it seems to be fixing the issue. Thank you for your excellent work on this gem! |
closing this issue since recent changes might have resolved this concern. Open a new issue if this persists. |
I have added
gem 'active_record_extended'
then
bundle
but I get this error
What could be the reason?
Gemfile.lock
config/boot.rb
config/application.rb
config/enviroment.rb
The text was updated successfully, but these errors were encountered: