You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This particular line of code is problematic for ActiveAdmin users, as well. If you use ActiveAdmin #includes on a has_one through, you will trigger a call to ransack. ActiveAdmin is feeding ransack the association through the parent, with the result that ransack is told to expect to find grandparent_id that does not exist. This line throws undefined method `type' for nil:NilClass.
Suppose class Whatever < ApplicationRecord has_one :grandparent, through: :parent. ActiveAdmin sends ransack instructions to look for whatevers.grandparent_id.
I can't help but feel there is inadequate error checking here in ransack. Further up the trace in
lib/ransack/nodes/condition.rb:25:in `extract'
there is this comment:
# TODO: Figure out what to do with multiple types of attributes,
# if anything. Tempted to go with "garbage in, garbage out" here.
Not being a ransack expert I can't say what the solution would be. But I can say this is a new error introduced since rack 3 and it seems improperly handled.
Working scenario:
Parent.ransack(full_name_cont: 'a').result # works correctly
Error scenario:
Child.ransack(parent_full_name_cont: 'a').result
Result:
The text was updated successfully, but these errors were encountered: