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 with_connection for an instance of ActiveRecord::ConnectionAdapters::PostgreSQLAdapter #1491

Open
vineelvineel opened this issue May 7, 2024 · 3 comments · May be fixed by #1493
Open

Comments

@vineelvineel
Copy link

vineelvineel commented May 7, 2024

I am using edge rails and it fails with this rails commit()

i am getting this error when i use ransack queries. When i use AR queries, the error does not happen.

NoMethodError (undefined method `with_connection' for an instance of ActiveRecord::ConnectionAdapters::PostgreSQLAdapter):
  
rails (d7980c6b1091) activerecord/lib/active_record/associations/alias_tracker.rb:10:in `create'
ransack (4.1.1) lib/ransack/adapters/active_record/context.rb:281:in `build_joins'
ransack (4.1.1) lib/ransack/adapters/active_record/context.rb:249:in `join_dependency'
ransack (4.1.1) lib/ransack/context.rb:40:in `initialize'
ransack (4.1.1) lib/ransack/context.rb:13:in `new'
ransack (4.1.1) lib/ransack/context.rb:13:in `for_class'
ransack (4.1.1) lib/ransack/context.rb:27:in `for'
ransack (4.1.1) lib/ransack/search.rb:32:in `initialize'
ransack (4.1.1) lib/ransack/adapters/active_record/base.rb:16:in `new'
ransack (4.1.1) lib/ransack/adapters/active_record/base.rb:16:in `ransack'
activeadmin (3.2.1) lib/active_admin/resource_controller/data_access.rb:218:in `apply_filtering'
activeadmin (3.2.1) lib/active_admin/resource_controller/data_access.rb:60:in `block in find_collection'
activeadmin (3.2.1) lib/active_admin/resource_controller/data_access.rb:59:in `each'
activeadmin (3.2.1) lib/active_admin/resource_controller/data_access.rb:59:in `find_collection'
activeadmin (3.2.1) lib/active_admin/resource_controller/data_access.rb:45:in `collection'
inherited_resources (1.14.0) lib/inherited_resources/actions.rb:7:in `index'
activeadmin (3.2.1) lib/active_admin/resource_controller/streaming.rb:13:in `index'
rails (d7980c6b1091) actionpack/lib/action_controller/metal/basic_implicit_render.rb:8:in `send_action'
rails (d7980c6b1091) actionpack/lib/abstract_controller/base.rb:226:in `process_action'
rails (d7980c6b1091) actionpack/lib/action_controller/metal/rendering.rb:193:in `process_action'
rails (d7980c6b1091) actionpack/lib/abstract_controller/callbacks.rb:261:in `block in process_action'
rails (d7980c6b1091) activesupport/lib/active_support/callbacks.rb:121:in `block in run_callbacks'
rails (d7980c6b1091) actiontext/lib/action_text/rendering.rb:25:in `with_renderer'
rails (d7980c6b1091) actiontext/lib/action_text/engine.rb:71:in `block (4 levels) in <class:Engine>'
rails (d7980c6b1091) activesupport/lib/active_support/callbacks.rb:130:in `instance_exec'
rails (d7980c6b1091) activesupport/lib/active_support/callbacks.rb:130:in `block in run_callbacks'
@robinator
Copy link

This error is caused because the API for creating an ActiveRecord::Associations::AliasTracker has changed in edge rails. It now wants to eat a connection pool rather than a connection. Knowing nothing about ransack's internals, from what I can tell it shouldn't need to use this API directly, and should just ask it's ActiveRecord::Relation to create a fresh AliasTracker instead.

I have a PR to fix in ransack here

@vineelvineel
Copy link
Author

This makes so much sense.

@vineelvineel
Copy link
Author

I can confirm, this works. I no longer get the with_connection error.

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 a pull request may close this issue.

2 participants