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

Rails 7.2 - LoadError: cannot load such file -- polyamorous/activerecord_7.2_ruby_2/join_association (LoadError) #1518

Open
EverardB opened this issue Aug 26, 2024 · 6 comments · May be fixed by #1534

Comments

@EverardB
Copy link

Upgrade to rails 7.2 and you will get the following message whilst constructing the database...

bin/rails aborted!
LoadError: cannot load such file -- polyamorous/activerecord_7.2_ruby_2/join_association (LoadError)
Did you mean? polyamorous/activerecord_7.0_ruby_2/join_association
polyamorous/activerecord_6.1_ruby_2/join_association
polyamorous/activerecord_6.0_ruby_2/join_association

@EverardB
Copy link
Author

It seems that this is a fairly important issue to fix... ransack can not be used out-of-the-box in any project from rails 7.1+

@scarroll32
Copy link
Member

#1519 (comment)

PRs welcome

@dmytro-strukov
Copy link

@scarroll32 Maybe it will help someone who is also debugging this issue.

Rails 7.2.1
Ruby 3.2.2

x = ArticleCategory.ransack(title_eq: 'Child category')
x.result

It produces the next SELECT "article_categories".* FROM "article_categories" /* loading for pp */ LIMIT $1 [["LIMIT", 11]]

It returns all of the records (should not).

Backtrace of the calls:

ransack-4.2.1/lib/ransack/adapters/active_record/base.rb:15

def ransack(params = {}, options = {})
  Search.new(self, params, options)
end

ransack-4.2.1/lib/ransack/search.rb:43

def result(opts = {})
  @context.evaluate(self, opts)
end

ransack-4.2.1/lib/ransack/adapters/active_record/context.rb:27

def evaluate(search, opts = {})
  viz = Visitor.new
  relation = @object.where(viz.accept(search.base))
   ...
end

ransack-4.2.1/lib/ransack/visitor.rb
viz.accept will call visit method here:

def visit(object)
  send(DISPATCH[object.class], object)
end

and this will call visit_Ransack_Nodes_Condition and visit_Ransack_Nodes_Grouping.

The strange behavior that I noticed is that Ransack::Nodes::Condition does not have attributes, it returns an empty array. I read test cases so probably it is not correct behavior, also I run tests locally and they are all green, so the current issue is not covered by them.

@dmytro-strukov
Copy link

@EverardB Which versions of Ransack and Rails do you use?

@scarroll32
Copy link
Member

@dmytro-strukov
Copy link

@scarroll32 Could you please provide steps to reproduce the issue?

@jdlubrano jdlubrano linked a pull request Oct 29, 2024 that will close this issue
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.

3 participants